<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Ed Glas's blog on VSTS load testing : Validation Rule</title><link>http://blogs.msdn.com/edglas/archive/tags/Validation+Rule/default.aspx</link><description>Tags: Validation Rule</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>Event ordering in Web Tests</title><link>http://blogs.msdn.com/edglas/archive/2008/08/28/event-ordering-in-web-tests.aspx</link><pubDate>Thu, 28 Aug 2008 18:49:49 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8903574</guid><dc:creator>edglas</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/edglas/comments/8903574.aspx</comments><wfw:commentRss>http://blogs.msdn.com/edglas/commentrss.aspx?PostID=8903574</wfw:commentRss><description>&lt;p&gt;Web tests have a number of extensibility points before and after a request. What order do they run in?&lt;/p&gt; &lt;p&gt;The hooks are:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;WebTestPlugin.PreRequest&lt;/p&gt; &lt;p&gt;WebTestRequestPlugin.PreRequest&lt;/p&gt; &lt;p&gt;ExtractionRule.Extract&lt;/p&gt; &lt;p&gt;ValidationRule.Validate&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Here is a sequence diagram that shows what order things fire:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edglas/WindowsLiveWriter/EventorderinginWebTests_A551/ResultsSequence_2.jpg"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="1086" alt="ResultsSequence" src="http://blogs.msdn.com/blogfiles/edglas/WindowsLiveWriter/EventorderinginWebTests_A551/ResultsSequence_thumb.jpg" width="740" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;There is no guaranteed order of firing for WebTestPlugin.PreRequest and RequestPlugin.PreRequest. Also if you have &amp;gt;1 Extraction or Validation rule on a request there is no guaranteed order they are run in.&lt;/p&gt; &lt;p&gt;Also note that Pre and Post request events do not fire by default for dependents. You can hook the PostRequest call on a top level request and iterate through dependents to wire up event handlers if you need that functionality.&lt;/p&gt; &lt;p&gt;Ed.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8903574" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/edglas/archive/tags/Visual+Studio+Team+Test/default.aspx">Visual Studio Team Test</category><category domain="http://blogs.msdn.com/edglas/archive/tags/Web+Test/default.aspx">Web Test</category><category domain="http://blogs.msdn.com/edglas/archive/tags/tsbt-tst/default.aspx">tsbt-tst</category><category domain="http://blogs.msdn.com/edglas/archive/tags/Extraction+Rules/default.aspx">Extraction Rules</category><category domain="http://blogs.msdn.com/edglas/archive/tags/Validation+Rule/default.aspx">Validation Rule</category></item><item><title>New templates for plugins and rules</title><link>http://blogs.msdn.com/edglas/archive/2008/08/19/new-templates-for-plugins-and-rules.aspx</link><pubDate>Tue, 19 Aug 2008 10:30:35 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8878085</guid><dc:creator>edglas</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/edglas/comments/8878085.aspx</comments><wfw:commentRss>http://blogs.msdn.com/edglas/commentrss.aspx?PostID=8878085</wfw:commentRss><description>&lt;p&gt;Inspired by templates developed by Dennis Bass of the services test labs, I added new item templates to the codeplex.com\TeamTestPlugins project.&lt;/p&gt; &lt;p&gt;If you install these on your machine it makes creating new plugins much easier:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/edglas/WindowsLiveWriter/Newtemplatesforpluginsandrules_314E/image_4.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="388" alt="image" src="http://blogs.msdn.com/blogfiles/edglas/WindowsLiveWriter/Newtemplatesforpluginsandrules_314E/image_thumb_1.png" width="642" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;If you work with web and load tests you'll find these very handy, and they are xcopy-installed on your machine (you'll have them working in less than 5 minutes).&lt;/p&gt; &lt;p&gt;Now to get these in our next release. :)&lt;/p&gt; &lt;p&gt;Ed.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8878085" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/edglas/archive/tags/Visual+Studio+Team+Test/default.aspx">Visual Studio Team Test</category><category domain="http://blogs.msdn.com/edglas/archive/tags/Web+Test/default.aspx">Web Test</category><category domain="http://blogs.msdn.com/edglas/archive/tags/Load+Test/default.aspx">Load Test</category><category domain="http://blogs.msdn.com/edglas/archive/tags/tsbt-tst/default.aspx">tsbt-tst</category><category domain="http://blogs.msdn.com/edglas/archive/tags/Extraction+Rules/default.aspx">Extraction Rules</category><category domain="http://blogs.msdn.com/edglas/archive/tags/Validation+Rule/default.aspx">Validation Rule</category></item><item><title>Catching errors as they happen: WebTest ValidateResponseUrl</title><link>http://blogs.msdn.com/edglas/archive/2008/06/24/catching-errors-as-they-happen-webtest-validateresponseurl.aspx</link><pubDate>Tue, 24 Jun 2008 16:20:55 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8647188</guid><dc:creator>edglas</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/edglas/comments/8647188.aspx</comments><wfw:commentRss>http://blogs.msdn.com/edglas/commentrss.aspx?PostID=8647188</wfw:commentRss><description>&lt;p&gt;In VS 2008, we added a new Validation Rule ValidateResponseUrl.&lt;/p&gt; &lt;p&gt;In VS 2005, a very common problem was that a page would redirect to the error page, but the web test engine did not automatically recognize this as an error. Then downstream in the playback another page would fail, usually with "hidden field blah not found in the context" error, as a side effect of the earlier error. Many times these errors would happen in a load test, but since it wasn't trapped as an error there was no error log for the page to figure out what was going on. &lt;/p&gt; &lt;p&gt;Many users hit this problem in 2005, and since the "side-effect" error was reported, but not the actual error, it was very confusing. This is problem is covered in both &lt;a href="http://msdn2.microsoft.com/en-us/library/ms364082(VS.80).aspx"&gt;&lt;u&gt;Web Test Authoring and Debugging Techniques&lt;/u&gt;&lt;/a&gt;, as well as Sean Lumley's great posts: &lt;a href="http://blogs.msdn.com/slumley/archive/2007/04/10/debugging-web-tests.aspx"&gt;Debugging Web Tests&lt;/a&gt; and &lt;a href="http://blogs.msdn.com/slumley/archive/2007/11/19/debugging-load-test-errors.aspx"&gt;Debugging Load Test Errors&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;In order automatically catch redirects to the error page (which is exactly the case Sean documents in the Debugging Load Test Errors post), we 1) added the Expected Response URL property to web test requests, and 2) added test-level validation rules that apply to every request, and 3) automatically add the Response URL validation rule at the test level. Now if a page redirects to the error page, that page will fail. This is essential in a load test as it enables you to get the error details for that page.&lt;/p&gt; &lt;p&gt;&lt;font size="4"&gt;Why does my web test pass if I run it, but fail if I run it in a load test?&lt;/font&gt;&lt;/p&gt; &lt;p&gt;The new rule can lead to unexpected failures in a load test.&lt;/p&gt; &lt;p&gt;In VS 2008, we also beefed up our vUser context in a load test. One thing the context now carries from iteration to iteration is the set of cookies for a user (thus emulating the browser cookie store). Let me take a typical example of how this can trip up your web test in a typical shopping cart type app. Record a web test as following:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;Browse to an item and put it in your cart&lt;br&gt;Go to checkout&lt;br&gt;Checkout requires login, so app redirects to login&lt;br&gt;Login, which sets a cookie&lt;br&gt;Login redirects to checkout&lt;br&gt;Checkout&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;When you run this in a load test, the vUser context will be carried from iteration to iteration, and the context contains any cookies set in a previous iteration. So the second iteration for the vUser will look like this: &lt;blockquote&gt; &lt;p&gt;Browse to an item and put it in your cart&lt;br&gt;Go to checkout&lt;br&gt;Checkout requires login, but now the user is already logged in (cookie is set) so app goes straight to checkout&lt;br&gt;The ValidateResponseUrl rule fails the web test because it is expecting to redirect to the login page&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;To fix this, you must explicitly log your user in during recording rather than counting on the redirect. If you only want the user to login once you can use the vUser Init and terminate functions in the load test test mix settings. &lt;p&gt;Ed.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8647188" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/edglas/archive/tags/Visual+Studio+Team+Test/default.aspx">Visual Studio Team Test</category><category domain="http://blogs.msdn.com/edglas/archive/tags/Web+Test/default.aspx">Web Test</category><category domain="http://blogs.msdn.com/edglas/archive/tags/Load+Test/default.aspx">Load Test</category><category domain="http://blogs.msdn.com/edglas/archive/tags/tsbt-tst/default.aspx">tsbt-tst</category><category domain="http://blogs.msdn.com/edglas/archive/tags/Validation+Rule/default.aspx">Validation Rule</category></item></channel></rss>