Software dev, tech, mind hacks and the occasional personal bit

NUnit Test Runners Were Not All Made Equal

NUnit tests can be run using a variety of different runners. Some common ones are:

The NUnit GUI and Test Driven create a new instance of the test class for each test run. This leads to more isolation but potentially slower performance.

Resharper and NUnit MSBuild Task re-use the same instance of the test class when running each test in the class. This can lead to unintended interaction between tests. Using these runners, it is vital to to assign initial values to instance variables in SetUp, rather than when they are defined or in the constructor.

If you use a mix of different test runners, you can end up with tests that pass on some machines and fail on others (eg, Test Driven locally works fine, but you use NUnit MSBuild Task on your build box and get intermittent failures).

Previous

NUnit SetUp Attribute and Subclassed Test Cases

Next

Loan Calulator: Monthly repayment and interest breakdown

1 Comment

  1. Also, be aware that test runners also differs in whether they run in STA or MTA by default; and with R#5, the test runner changed this behaviour. This is significant when testing windws UI code.

Powered by WordPress & Theme by Anders Norén