We talked before about Microsoft
Pex,
and how it choose the shown
inputs.
We then talked more about building blocks of parameterized unit
tests
and its
patterns.
What we missed till now is how to debug your parameterized unit tests.
In order to debug your parameterized unit tests, do the following:
- Go to Tools >> Options >> Pex >> Diagnostic.
- Change the BreakOnStart option to True.
- Now set a break point at any line of code inside your parameterized
unit test.
- Right click inside your parameterized unit test and select Run Pex
Explorations.
- You will see a dialog popping asking to attach a debugger.
- Select your current Visual Studio instance.
- Once attached, press F5.
- Now Visual Studio debugger will jump to your break point in the
parameterized unit test and stop there. You can now step through you
parameterized unit test code.
You will notice that parameter’s values are those selected by
Pex.
The debugger will run the parameterized unit test for each input
value(s) chosen by Pex, So you can inspect the PUT behavior against a
specific input value.