unit-testing

How do I test modal dialogs with Selenium?

I'm getting started with Selenium IDE and trying to test a webapp that's full of model dialogs (window.showModalDialog). Recording the test seems to work (except there's nothing in the log when the dialog pops up) but they don't play back properly. The script actually opens the window (triggered by a button click), but then just waits i...

Help running NUnit from dos command line.

I am working on an MSBuilds script to run my NUnit tests from CruiseControl.Net. _Test_DAL has three tests in it. I am having problem getting the right dos command to run the NUnit. Here is the command to run NUnit but it does not find any tests. D:\CC\JCDCHelper\Source_Test_DAL\bin\Debug>"C:\Program Files\NUnit 2.4.3\bin\nun...

Running unittest.main() from a module?

I wrote a little function that dynamically defines unittest.TestCase classes (trivial version below). When I moved it out of the same source file into its own module, I can't figure out how to get unittest to discover the new classes. Calling unittest.main() from either file doesn't execute any tests. factory.py: import unittest _tes...

Unit Testing the Data Access Layer - Testing Update Methods?

I'm looking into adding some unit tests for some classes in my data access layer and I'm looking at an update routine that has no return value. It simply updates a row based on the id you provide at whichever column name you provide. Inside of this method, we collect the parameters and pass them to a helper routine which calls the st...

What techniques work for abstracting session in ASP.NET MVC and maintaining testability.

I'm currently working on a large scale ASP.NET MVC application and one area where testing is failing is around things that we're storing in session. My first pass at abstracting session is just to create a very simple static class and make all calls to session go through that. So I might have something like this: public static class A...

which build tool(s) do you recommend for python?

I'm starting a small/medium-sized python project, likely in Test Driven Development. My backgrounds are more in C and java than python (I used ant and makefile) I know that in python you might not need a build tool, but I will, because I'll use cython and PyInstaller (the thing should work on a couple of different UNIXes, without depend...

How do you prefer to organize your test data in Ruby On Rails?

How do you prefer to organize your test data in Ruby On Rails: fixtures, object factories or anything else? Why? ...

What is the most difficult UnitTest case you have ever encountered?

One of the most difficult test cases I have encountered is testing features that operates on files and folders. It is not easy to mock or simulate files and folders. ...

BizTalk testing maps with multiple input xml or is it Inline C# that is the problem?

Can anyone explain how to get unit tests of BizTalk maps with multiple inputs to work? I've been happily using the examples on Michael Stephenson blog to test my maps, but I've just tried my first multiple input map and it's failing :-( I've used the VS2005 "Test Map" to first generate an input instance with the two input messages, th...

Is there a UI unit test framework that can test interactions with modal dialogs (via showModalDialog)?

I'm trying to do some unit/integration tests between pages of my ASP.NET site but can't seem to find any tool that can work effectively with modal dialogs generated by the showModalDialog command (FF3, IE). Does anyone have experience testing these annoying things? Update: @bbmud was right--WatiN supports modal dialogs very well. Her...

Unit tests for code accessing ActiveDirectory

What's the best way to unit test an application accessing the ActiveDirectory and/or mock the dependencies to the AD? All the required types such as DirectorySearcher and DirectoryEntry don't appear to be easily mockable. We've got methods like FindByUserName() and would like to (unit) test them. ...

Mock ASP.Net User in WebForms app

I have a legacy app that I am trying to build some testing into. I have some tests that require the HttpContext.Current.User Is there a way to mock this, or simply login a user on the fly? ...

Mocking Spring MVC BindingResult when using annotations

I'm migrating a Spring MVC controller to use the newer style annotations, and want to unit test a controller method that validates a command object (see simple example below). @RequestMapping(method = RequestMethod.POST) public String doThing(Command command, BindingResult result, HttpServletRequest request, HttpSer...

Are unit tests and acceptance tests enough?

If I have unit tests for each class and/or member function and acceptance tests for every user story do I have enough tests to ensure the project functions as expected? For instance if I have unit tests and acceptance tests for a feature do I still need integration tests or should the unit and acceptance tests cover the same ground? Is ...

Value of type '<typename>' cannot be converted to <typename>.

I'm working on a project that uses the testing tool built into VS 2008. Periodically I will see an error comparable to: Value of type 'AcademyPro.Code.BLL.Appearance' cannot be converted to 'AcademyPro.Code.BLL.Appearance'. Type mismatch could be due to the mixing of a file reference with a project reference to assembly 'AcademyPro'. Tr...

Easy way to fill up ResultSet with data

Dear All, I want to mock a ResultSet. Seriously. I'm refactoring one big complicated piece of code which is parsing data from ResultSet, and I want my code to behave identically. So, I need to write a unit test for the piece being refactored to be able to test this. After googling I came up with 2 ideas: Use EasyMock, write looooong ...

Unit testing float operations in Visual Studio 2008 Pro

I have some C# unit tests that perform some float/double operations and I would like to unit test them. Assert.AreEqual is insufficient because of rounding errors. Take unit conversion as an example. 10.5 meters to feet has a conversion factor of 3.281 so I get 34.4505. Using a more accurate conversion factor gives me 34.4488189. I ...

Does there exist a site which hosts collections of unit tests in various fields?

Does there exist a site which hosts collections of unit tests in various fields? specifically, instead of digging and extracting the packages that seem close to your subject of coding, I'd like to use it like shared code, see how it was tested. (and then also know how it should work) So is there one like that? doesn't matter which progr...

How do you unit test classes that use timers internally?

Like it or not, occasionally you have have to write tests for classes that make internal use of timers. Say for example a class that takes reports of system availability and raises an event if the system has been down for too long public class SystemAvailabilityMonitor { public event Action SystemBecameUnavailable = delegate { }; pub...

How to use generics containing private types with Visual Studio Unit Tests

I have an issue with a class that I'm trying to test. I've declared a private enum and I'm using that in a generic dictionary in the code. This enum has no meaning outside of this class but it's used in a private method. When I generated the code the accessor is written into the generic dictionary type, but throws an invalid cast exce...