I'm having a strange issue with unit testing in Visual Studio 2010. I have a test that passes when I use "Debug test" (without any breakpoints), but failes when I use "Run test". This test uses external dll's, so I can't debug it properly.
Do you know of any reason why a situation like this is possible? Why "Debug test" is different than "Run test", when all other parameters are the same?
To start debugging: In the Visual Studio editor, set a breakpoint in one or more test methods that you want to debug. Because test methods can run in any order, set breakpoints in all the test methods that you want to debug. In Test Explorer, select the test method(s) and then choose Debug on the right-click menu.
In the case of a test failure you can follow these steps to debug it: Double click the failure entry from the Failures tab in the JUnit view to open the corresponding file in the editor. Set a breakpoint at the beginning of the test method. Select the test case and execute Debug As>JUnit Test from the Debug drop down.
Switch you solution to Release mode instead of Debug, run a full build, switch back to debug and retry and let me know the outcome, I think the tests will pass....
There can be several reasons, but to pin-point one, you'll have to give us some code to work with.
It could be code exclusion:
#ifdef _DEBUG
//do something
#endif
This will only be executed in debug mode.
It could be optimizations. Although they shouldn't normally affect the behavior, you shouldn't rely on destructors or copy constructors being called.
If you're doing any hacking inside the code, it might also only be valid for debug.
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