The test tree in the GUI relies upon attributes ordering when reloading.
Some compilers (at least VS2008 Express) seems to store attributes *sometimes* in different order on recompilation, it can lead to an inconsistent tree with duplicate nodes.
Consider the following test fixtures :
public class FixtureClass
[TestCase(1, Result = 2)]
[TestCase(2, Result = 4)]
public int ATestMethod(int a)
return a * 2;
Start the GUI: everything is fine so far.
Add another [TestCase(3, Result = 6)] and rebuild.
The GUI automatically reloads the tests and now ATestMethod appears with a duplicate test cases (see the attached screenshoot).
Here's a failing unit-test (TestSuiteTreeViewFixture.cs) that demonstrates the issue :
public void ReloadTreeDontRelyOnOrder()
CheckTree(treeView, suite, "initially");
TestSuite nunitNamespaceSuite = suite.Tests as TestSuite;
TestSuite testsNamespaceSuite = nunitNamespaceSuite.Tests as TestSuite;
TestSuite assembliesNamespaceSuite = testsNamespaceSuite.Tests as TestSuite;
TestSuite mockTestFixture = assembliesNamespaceSuite.Tests as TestSuite;
// Just swap the first and second test
object first = mockTestFixture.Tests;
CheckTree(treeView, suite, "after reordering");
It fails with the following message:
Tree out of order after reordering: Incorrect count for NUnit.Tests.Assemblies.MockTestFixture
But was: 19