Search code examples
.netunit-testingdebuggingnunittestcase

Running all tests but stop and debug one of them


I am testing a .NET dll and i have written 5 NUnit tests against it.All tests share a common object that gets initialized in the OneTimeSetUp.When i press RunAll 4/5 tests return correct.The fifth one works fine when running alone.

Is there any way to put the breakpoint in your target testcase,select Run-all and stop where you need? I need to inspect the state of the shared object in the test that fails.

Is it possible?

Example

public class State
{
  public int Value;
}

public class Tests{
   public State state=new State();
   [Testcase]
    public void Test1()
    {
      state.Value=1;
     }

   [Testcase]
   public void Test2()
   {
      state.Value=2;
   }
   ......
   [Testcase]
   public void TestN()
   {
     -----breakpoint
   }
}

Solution

  • Please try to use "debug" instead of "run all". Your run should stop on your breakpoint.