Team System Developer Center >
Visual Studio Team System Forums
>
Visual Studio Web Performance and Load Testing
>
How to fail a request
How to fail a request
Hi
So far I've always been able to do what was needed via .webtest. Now there are few things that require coding which I'm not too much familiar with.
When I create the code from webtest what language are we using?
Here's what I'm trying to do:
When I get to a certain page I extract the total (TotalCount = 5)
After I add a user the total become 6 which I also extract. (TotalCount2 = 6)
Now I want to say
extractionRule12.ContextParameterName = TotalCount2
extractionRule10.ContextParameterName = TotalCountif
{
I want to fail the request here. How do I do that"
}
Thanks
(extractionRule12.ContextParameterName == extractionRule10.ContextParameterName + 1)
Answers
- Hello,
The language of coded web test depends on the project choice in the prompted dialog while creating a new web test through Test->New Test.
To fail a request, you need to write a request level plug-in and set the outcome of request in it after upgrading to SP1. To use the context parameter in plug in, we could utilize 'e.WebTest.Context["ContextName"]' instead.
The codes I tested on my machine are shown below and you may refer to:
public class Class1:WebTestRequestPlugin
{
public override void PostRequest(object sender, PostRequestEventArgs e)
{
if (e.WebTest.Context["Total"].ToString()=="Dda")
{
e.Request.Outcome = Outcome.Fail;
}
}
}
About how to write a request level plug in, you may refer to the following article :
http://msdn.microsoft.com/en-us/library/bb514192.aspx
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.- Marked As Answer byslumley MSFTMSFT, ModeratorThursday, November 05, 2009 3:26 PM
All Replies
- Hi halchal,
You can fail a request using the Outcome:
http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.testtools.webtesting.webtestrequest.outcome.aspx
Refer also to these forum posts:
Navantis - Hello,
The language of coded web test depends on the project choice in the prompted dialog while creating a new web test through Test->New Test.
To fail a request, you need to write a request level plug-in and set the outcome of request in it after upgrading to SP1. To use the context parameter in plug in, we could utilize 'e.WebTest.Context["ContextName"]' instead.
The codes I tested on my machine are shown below and you may refer to:
public class Class1:WebTestRequestPlugin
{
public override void PostRequest(object sender, PostRequestEventArgs e)
{
if (e.WebTest.Context["Total"].ToString()=="Dda")
{
e.Request.Outcome = Outcome.Fail;
}
}
}
About how to write a request level plug in, you may refer to the following article :
http://msdn.microsoft.com/en-us/library/bb514192.aspx
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Send us any feedback you have about the help from MSFT at fbmsdn@microsoft.com.- Marked As Answer byslumley MSFTMSFT, ModeratorThursday, November 05, 2009 3:26 PM


