4. Edit webtest
9. Create a webtest plug-in
• Web Test plug-in for isolation Web In the testCodeProvides a means. Custom Web The test plug-in is running Web Some code can be called during testing. In each test iteration, Web The test plug-in must run once. • From Webtestplugin The base class is derived from your own class and you can create a custom Web Test the plug-in. • You can customize Web The test plug-in is used for recorded Web Test, which allows you to obtain Web More control of the test. They can also be used for encoding Web Test.
By default, webtest does not provide a predefined webtest plug-in:
Create a webtest Plugin:
1. Create a class library project
2. Right-click and select "add reference ".
On the ". Net" tab, select "Microsoft. visualstudio. testtools. webtesting ". Click OK ".
3. Write a code for obtaining the number of tests and use the sample code provided on msdn:
Using system;
Using system. Collections. Generic;
Using system. text;
Using Microsoft. visualstudio. testtools. webtesting; namespace samplerules
{
Public class samplewebtestplugin: webtestplugin
{
Static int testiterationnumber; Public override void postwebtest (Object sender, postwebtesteventargs E)
{
} Public override void prewebtest (Object sender, prewebtesteventargs E)
{
E. webtest. Context ["testiterationnumber"] = testiterationnumber;
Testiterationnumber ++;
}
}
}
4. Build a class library and add the generated DLL file to the test project.
5. Click the set web test plug-in button again to view the mywebtestplugin
Click OK to add mywebtestplugin to the Web Test plug-in the webtest attribute:
6. After this plug-in is added, the number of test iterations will be recorded during the test.
7. Download The mywebtestplugin demo.
10. other editing functions
Select webtest and right-click to view the provided editing functions, such as manually adding requests, adding Web Service requests, and adding comments,