سؤال

I am having an interesting situation. In my test assembly, I have folders having specific test classes, i.e., TestFixture's. Consider, for e.g., the following hierarchy in VS:

Sol
  TestProject
    TestFolder1
      TestClass1
      TestClass2
    TestFolder2
      TestClass3

Now, when I run the following at command line:

nunit-console.exe /run:Sol.TestProject.TestFolder1.TestClass2 TestProject.dll

Things are running fine and all the tests are passing. But, if I run as below:

nunit-console.exe /run:Sol.TestProject.TestFolder1 TestProject.dll

In this case, some of the tests in TestClass2 are failing.

I have tried dumping the state of some of the relevant objects involved in the test, and the state seemed fine at the beginning of the test code in both cases. Also, TestClass1/2/3 do not have a superclass doing something - so that is ruled out as well. Any ideas what else can be happening here?

I am using VS2010/.NET4.0 (4.0.30319.1)/nUnit 2.5.9.

هل كانت مفيدة؟

المحلول

Finally figured this out. I was using a singleton class for storing certain options. Looks like the singleton class instance is retained between runs of different TestFixtures (i.e., test classes), when they are run together, e.g., for a folder or for a project. I did not dump the state of this object initially, because I thought that the singleton class will be having new instance for each of the TestFixtures. Interesting finding, hope this helps someone.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top