unit-testing

How can we execute Unit Tests against DOM manipulation?

The introduction to QUnit over at netTuts.com spawns an interesting exchange (never resolved) over how to apply unit tests against actions that manipulate the DOM. The following quote (Alex York) gets to the crux: What would be nice is that if you had a function like this: function add(a, b) { var result = a + b; $(“input#...

How should I test a model with a lot of attributes and validations in Ruby on Rails?

Hi I have a user model with a lot of attributes and validation that I require to go in. I want to develop my application using test-driven development but am having a hard time writing simple tests for validations such as no blank emails, unique emails, proper email address. So what's the best way to start writing tests? ...

How to get a list of elements with Watin?

I'm trying to use Watin for testing. And I need to get a list of elements with specific properties, e.g. all links that have "Go" title. I was trying this: browser.Link(link => link.Text == "Go"); but it returns only one element. Also I was trying this: var links = from link in browser.Elements where link.Text ==...

How to mark expected failures in SUnit?

How can I mark a unit test in SUnit (or phexample) as expected failures? ...

How should I unit test the serialization of an Exception class?

What's the best way to unit test the Serialization of an Exception class like this: [Serializable] public abstract class TankBaseException : Exception { public TankBaseException() : base() { } public TankBaseException(string message) : base(message) { } public TankBaseException(string message, Exception innerException) : b...

How can I Unit Test Gestures in android?

I want to unit test a swipe left/right action on the screen in Android but I haven't been able to find any documentation on it. Can anyone lend a hand? Can it even be done? ...

Overwritting PHPUnit test files with updated ones in NetBeans

Hello, Using NetBeans 6.9.1, when I update my source files with additional unit tests for PHPUnit, I always have to delete the old PHPUnit test files and generate new ones. If I choose to generate without deleting them, generation will fail and the old files won't be updated. Is there a "smart" way to force NetBeans to automatically over...

How do you write a unit test for a regex pattern?

Is it possible? Would it require a existing whitewashed and/or blacklisted datasets, or not? How would you know an exception did not exist? ...

How to test with NSUserDefaults?

Hello! In most of my classes that work with defaults I make the defaults object settable: @property(retain) NSUserDefaults *defaults; This is supposed to make testing easier: // In a nearby test class: - (void) setUp { [super setUp]; NSUserDefaults *isolatedDefaults = [[NSUserDefaults alloc] init]; [someObjectBeingTested ...

Implementing a protected parameterless constructor for unit testing

If I have a type with a big-old (lots of params) constructor, is it a valid approach to implement a protected parameterless constructor simply for the purposes of creating a derived "Fake" type to use for stubbing in unit tests? The alternative is to extract an interface, but this is not always desireable in a codebase you do not have f...

How do I set up NUnit to run my project's unit tests?

I'm starting to use NUnit to write test cases in C# and Visual Studio 2010 and .NET 4.0. I want to use NUnit to test against a DLL (a C# class library project)'s public functions. How do I set up NUnit to work with my project? Should I add UNnit code to the same class library project to test against? Or add a separate project in the...

Symfony Unit Test Won't load app_ globals

I'm attempting to create a unit test for my app in Symfony. My /config/app.yml looks like this: all: tmp_dir: "tmp" # usps usps_username: xxxxx usps_password: xxxxx usps_dir: usps in the unit test, when I run something like: $t->comment(sfConfig::get('app_usps_username')); It will just output and empty line. What's goin...

How do I test an abstract class's protected abstract method?

I've been working on the best way to test an abstract class named TabsActionFilter. I've guranteed that classes that inherit from TabsActionFilter will have a method called GetCustomer. In practice this design seems to work well. Where I've had some issues is figuring out how to test the OnActionExecuted method of the base class. This m...

Determine which Unit Tests to Run Based on Diffs

Does anyone know of a tool that can help determine which unit tests should be run based on the diffs from a commit? For example, assume a developer commits something that only changes one line of code. Now, assume that I have 1000 unit tests, with code coverage data for each unit test (or maybe just for each test suite). It is unlikel...

Selenium Page Object Reuse

I really like how selenium 2 by convention pushes you towards using PageObjects as POJOs, and then simply using the PageFactory to instantiate the fields in this class. What I am finding limiting is that we reuse a lot of elements on many different pages. The big problem is that these reused components do not have the same id / name wh...

WSDL Generation and interfaces for testability

I have a webservice that I want to Consume in my application. Too be able to test the other parts of the application I have built an Interface that allows me to test using mocks and stubs. I can add the Interface to the generated code from the web service, however if at any point in time a regenerate the code I loose the Interface on t...

Testing a model spec that uses an after_create callback

Guys, Here is a model that I'm using, I've simplified it a bit down to the simplest form that still fails my example: class User < ActiveRecord::Base after_create :setup_lists def setup_lists List.create(:user_id => self.id, :name => "current") List.create(:user_id => self.id, :name => "master") end end And I'd like t...

Loading a text file from AndroidTestProject

I have two projects, my main android application and another test project that runs on top of that android application. I have placed a text file in my android test project, This file contains information xml content. The xml content is what my android application will receive when I hit my server. I am using the TestCase class in my ...

CakePHP test - unit Testing

I am new to testing or so called unit testing. i am on the verge of finishing a web application. i wanna know is unit testing important. and how does it help ? as i have never written a test. can i get reference to some kinda guide or tutoriials regarding to writing test ? i am using cakephp framework. ...

Is possible to run some Unit Tests as smoke tests from an .aspx?

In my project we use UnitTests (MsTest). We run them manually and in the build script. But for some environments where we deploy manually. We are in the need of having some smoke tests. At the moment I made this smoke tests "manually" (Login, create an user, create a licence, create a product, etc). I know I can run unit tests from co...