在 TFS 2015 版本定义中使用 MSTest 运行 网络测试

Using MSTest within a TFS 2015 Release Definition to run a webtest

我有一个正在构建的 *.webtest 作为 TFS 2015 版本定义的一部分。我想 运行 此测试作为发布的一部分。

我认为这需要 mstest.exe 但是 mstest 命令在 Command Line 组件中 运行 时无法识别,这与 dotnet publish 等其他命令不同.

我是否需要在我的测试项目中包含 MSTest.exe 可执行文件,或者是否有更多 "out of the box" 方法在 TFS 2015 版本定义中进行 运行 网络测试?

您可以运行通过MSBuild工具进行WebTests,您可以通过PowerShell调用MSBuild工具。

  1. 添加 PowerShell 任务

代码:

        param (    
        $tool = "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\MSTest.exe",   
         $path ,   
         $include = "*.webtest",   
         $results ,    
        $testsettings)
            $web_tests = get-ChildItem -Path $paths -Recurse -Include $include

foreach ($item in $web_tests)
     {   

     $args += "/TestContainer:$item "

    }

    & $tool $args /resultsfile:$Results /testsettings:$testsettings
  1. 添加发布测试结果任务

更多信息,可以参考这篇文章:Running WebTests as part of a VSTS VNext Release pipeline