Introduction:
There are a wide range of applications which perform according to various circumstances.Some are fast and some are slow.When we hit a particular request ,there is a timeout value set to determine whether the request has been processed within the desired time limit set.In order to set the request timeout property there is an option in Visual Studio Webtest for each request properties to set the Timeout value.
But if there are a large no. of requests in your Webtest ,changing the value for each and every request is a tedious task.But not to worry,this is where the Webtest plugins comes in handy! The request timeout property for the all the requests inside a Webtest can manged with a single property.Here are steps which has to be followed :
1.Create a Web Performance and Load Test Project in Visual Studio as shown below :
2.Right click the project and add a new item :
3.Choose Class item from the menu and give desired name for the plugin file :
4.Implement the code as shown below for adding Request timeout using this plugin :
Note : Don't forget to include the following headers :
using Microsoft.VisualStudio.TestTools.WebTesting;
7.Select Timeout plugin-in and set your desired input value for the requests Timeout.
There are a wide range of applications which perform according to various circumstances.Some are fast and some are slow.When we hit a particular request ,there is a timeout value set to determine whether the request has been processed within the desired time limit set.In order to set the request timeout property there is an option in Visual Studio Webtest for each request properties to set the Timeout value.
But if there are a large no. of requests in your Webtest ,changing the value for each and every request is a tedious task.But not to worry,this is where the Webtest plugins comes in handy! The request timeout property for the all the requests inside a Webtest can manged with a single property.Here are steps which has to be followed :
1.Create a Web Performance and Load Test Project in Visual Studio as shown below :
2.Right click the project and add a new item :
3.Choose Class item from the menu and give desired name for the plugin file :
4.Implement the code as shown below for adding Request timeout using this plugin :
using System;
using
System.Collections.Generic;
using System.Linq;
using System.Text;
using
System.Threading.Tasks;
using
Microsoft.VisualStudio.TestTools.WebTesting;
using
System.ComponentModel;
namespace SampleWebtest
{
[Description("This plugin can be used to set the
Timeout property for each request")]
public class Timeout : WebTestPlugin
{
public int timeout_seconds;
public override void PreRequest(object sender, PreRequestEventArgs e)
{
e.Request.Timeout =
timeout_seconds;//Setting time out value for each request
}
[DefaultValue(60)]
[Description("All requests will have their Timeout
Requests property set to this value")]
public int RequestTimeout
{
get
{
return timeout_seconds;
}
set
{
timeout_seconds = value;
}
}
}
}
using System.ComponentModel;
5.Build the solution.
6.Right Click the Webtest and select "Add Request Plugin".
7.Select Timeout plugin-in and set your desired input value for the requests Timeout.
Voila! You have successfully set the timeout value globally for all the requests in the Webtest.
Very Useful . Thank you so much.
ReplyDeleteMuch Appreciated!
Delete