• 转:创建WebTest插件


    Web测试插件为隔离Web测试中各个主声明语句外部的代码提供了一种手段。自定义的Web测试插件为在运行Web测试时调用某些代码提供了途径。在每个测试迭代中,Web测试插件都要运行一次。
    通过从WebTestPlugin基类派生您自己的类,可以创建自定义的Web测试插件。
    可以将自定义Web测试插件用于已记录的Web测试,这使您只需编写最少量的代码即可获得对Web测试的更大控制。此外,还可以将它们用于编码的Web测试。
    默认情况下,WebTest没有提供预定义的WebTest插件:

    创建一个WebTest Plugin:
    1、新建一个类库项目
    2、然后右击并选择“添加引用”。
    在“.NET”选项卡上,选择“Microsoft.VisualStudio.TestTools.WebTesting”。单击“确定”。
    3、编写一段获取测试次数的代码,使用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类库,将生成的Dll文件添加引用到测试项目中

    5、再次点击设置Web测试插件按钮,可以看到MyWebTestPlugin

    点击确定后,可以在WebTest属性中Web测试插件中添加了MyWebTestPlugin:

    6、添加此插件后,运行测试时,将记录下测试的迭代次数。

    7、MyWebTestPlugin Demo下载。

    10、其他编辑功能
    选中WebTest,点击右键,可以看到提供的编辑功能,例如:手动添加请求,添加Web服务请求,添加注释等等,
  • 相关阅读:
    CustomDrawableTextView
    Snippet: align a TextView around an image
    How to import library ?
    Gradle自定义你的BuildConfig
    使用adb shell dumpsys检测Android的Activity任务栈
    Activity intent经常使用的 FLAG
    使用 ContentProviderOperation 来提升性能
    幻方算法
    自己制作的粉碎机批处理程序
    Ubuntu 16.10 server 相关
  • 原文地址:https://www.cnblogs.com/lci05/p/3679338.html
Copyright © 2020-2023  润新知