Most of my recent posts have been about new features in VS 2010. This post is going to show you how to debug your custom rules. This applies to VS 2005, VS 2008 and VS 2010.
- First let’s create a Test Project
- Then Right click on the project node and select Add –> Web Test
- Record a simple web test
- Now add a new class to the project. We can re-use the sample extraction rule from this earlier post: Sample Extraction Rule Copy and paste the code from this sample into the new class file.
- Compile the project
- Right click on a request that has a post parameter and select the new rule:
- Enter a context parameter name, name of the form field to extract and the index of the form field to extract. I am going to enter _EVENTVALIDATION. Then click OK.
- The test is ready to run. If you click the play button in the web test editor the test will run and the you will see the results in the Web Test viewer. But what if your custom rule/plugin isn’t working as expected. When I playback my test, my rule failed to find the _EVENTVALIDATION field.
Debugging the rule
- First we need to place a break point in the custom rule. For an extraction rule, place a break point in the extract method.
- Now we need to start the test. This time we don’t want to just click play. If you hit the drop down on the web test editor play button, you will see that there are 4 options. This time choose Debug Test.
- When the test runs, it will hit your break point.
- Now we can step through and see why the rule failed.
- In my case I can see that when I typed in the form field, I missed a _. Now if I correct my mistake and rerun, I can see the value extracted into the context.
This shows you how to debug web tests rules/plugins. But the same applies to load test plugins. The load test editor play button is also a split button. So just place your break point in the load test plug-in and choose debug test instead of play test.
I hope this helps in debugging your custom rules.