Search code examples
visual-studiotfsmstesttfs-2015release-management

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


I have a *.webtest that I'm building as part of a TFS 2015 Release Definition. I'd like to run this test as part of the release.

I believe this requires mstest.exe however the mstest command is not recognized when running within the Command Line component, unlike other commands like dotnet publish.

Do I need to include the MSTest.exe executable within my test project or is there a more "out of the box" way to go about running webtests within a TFS 2015 Release Definition?


Solution

  • You can run WebTests through MSBuild tool, you can call MSBuild tool through PowerShell.

    1. Add PowerShell task

    Code:

            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. Add Publish Test Results task

    More information, you can refer to this article: Running WebTests as part of a VSTS VNext Release pipeline