My platform: Visual C# 2008 Express Edition with NUnit 2.2.7
I have a solution with my code in one project and my NUnit unit tests in a different project in the same solution.
I have been struggling hard to debug and single-step through the NUnit tests. I found some references online that suggested calling the following:
NUnit.ConsoleRunner.Runner.Main(args);
But this doesn't even compile - it has the compiler error:
Error 1 The type or namespace name 'Runner' does not exist in the namespace 'NUnit.ConsoleRunner' (are you missing an assembly reference?)
I've added every assembly reference I could find, to no effect.
Finally, this is what I have hacked together and it works, but perhaps you good readers could suggest a better solution:
1) In my test project, the class name of a test case that I want to debug is MyTestClass. It has a [TestFixtureSetUp] method named Init() and the actual test case is in [Test] function MyTest()
2) In my code project, I have a console program TestProgram.cs which compiles to an EXE.
In TestProgram.cs, I call the test cases in the following way
// First instantiate the test class
MyTestClass tc = new MyTestClass();
// Call the TestFixtureSetup method
tc.Init();
// Now call the actual test
tc.MyTest();
This works and I can debug and single step through the test cases.
If anyone has any better suggestions using Visual Studio 2008 Express without paying for additional plugins, I appreciate your advice.
Options. If the selection point in the current code window is within a NUnit test, then under the right mouse click context menu, there will be a new option "Jonno - Debug Current test". Set a break point within the text of the test, use the menu option, and you should be able to immediately debug your test.
To debug a failed test case you should: check that the input data is correct (open the test case to view and/or update the base level attribute values) check that the expected results are correct (in the Test Report, click on the expected result to view and/or update the expected results for that attribute)
Debug mode Open a test case and switch to the Script view. Double-click on the leftmost side of the script editor to mark a breakpoint. A breakpoint is where Katalon Studio pauses the test execution for you to start debugging. Choose a browser for Debug from the main toolbar.
Jon as a good way but not the more automatic one ;)
Here is what I already say on SO:
You can create a blank project (choose console application for example) and in the property of the project you can select DEBUG tag and select Start External Program
. Put the path of Nunit. Than, in the start option, the command line arguments select the DLL that contain all your test (mine is always in the nunit\bin...). Than select Enable unmanaged code debugging
and you will be able to start the project inside VS and even use the debugger step-by-step.
This way, you do not need macro or anything to be done every time, it's just a normal F5 :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With