Run MSTests

Octopus.Script exported 2015-04-30 by bobjwalker belongs to ‘Tests’ category.

This Step template should be used for running MSTests by passing list of assemblies.

Parameters

When steps based on the template are included in a project’s deployment process, the parameters below can be set.

Ms Test Path

MsTestExePath

null

Working directory

MsTestWorkingDirectoryPath

The folder that contains the test assemblies. Generally this will be bound to an output variable from a previous step. Example: #{Octopus.Action[Deploy integration tests].Output.Package.InstallationDirectoryPath}

Test assemblies

MsTestAssemblies

A semicolon-separated list of assembly names containing tests. Example: MyCompany.IntegrationTests.dll; MyCompany.SmokeTests.dll

Script body

Steps based on this template will execute the following PowerShell script.

Write-Output "Running MsTests tests..."

$exePath = '"' + $MsTestExePath + '"'
if (-not $exePath) {
    $exePath = "mstest.exe"
}

$runMsTest = "& $exePath "

$MsTestAssemblies.Split(";") | ForEach {
    $asm = " /testcontainer:"+$_.Trim()
    Write-Output "Including test container assembly $asm"
    $runMsTest += "$asm"
}
Write-Host $runMsTest
cd $MsTestWorkingDirectoryPath
Write-Host $MsTestWorkingDirectoryPath  

iex $runMsTest
$mstestExit = $lastExitCode


exit $mstestExit

Provided under the Apache License version 2.0.

Report an issue

To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.

{
  "Id": "75746f93-6c2b-4a52-b3b6-97e8dee09a81",
  "Name": "Run MSTests",
  "Description": "This Step template should be used for running MSTests by passing list of assemblies.",
  "Version": 14,
  "ExportedAt": "2015-04-30T12:44:24.644+00:00",
  "ActionType": "Octopus.Script",
  "Author": "bobjwalker",
  "Parameters": [
    {
      "Name": "MsTestExePath",
      "Label": "Ms Test Path",
      "HelpText": null,
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "MsTestWorkingDirectoryPath",
      "Label": "Working directory",
      "HelpText": "The folder that contains the test assemblies. Generally this will be bound to an output variable from a previous step. Example: _#{Octopus.Action[Deploy integration tests].Output.Package.InstallationDirectoryPath}_",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "MsTestAssemblies",
      "Label": "Test assemblies",
      "HelpText": "A semicolon-separated list of assembly names containing tests. Example: _MyCompany.IntegrationTests.dll; MyCompany.SmokeTests.dll_",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    }
  ],
  "Properties": {
    "Octopus.Action.Script.ScriptBody": "Write-Output \"Running MsTests tests...\"\n\n$exePath = '\"' + $MsTestExePath + '\"'\nif (-not $exePath) {\n    $exePath = \"mstest.exe\"\n}\n\n$runMsTest = \"& $exePath \"\n\n$MsTestAssemblies.Split(\";\") | ForEach {\n    $asm = \" /testcontainer:\"+$_.Trim()\n    Write-Output \"Including test container assembly $asm\"\n    $runMsTest += \"$asm\"\n}\nWrite-Host $runMsTest\ncd $MsTestWorkingDirectoryPath\nWrite-Host $MsTestWorkingDirectoryPath  \n\niex $runMsTest\n$mstestExit = $lastExitCode\n\n\nexit $mstestExit",
    "Octopus.Action.Script.Syntax": "PowerShell"
  },
  "Category": "Tests",
  "HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/run-mstest.json",
  "Website": "/step-templates/75746f93-6c2b-4a52-b3b6-97e8dee09a81",
  "Logo": "iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAIAAAAiOjnJAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAACiZJREFUeNrsnUFsVEUYx7fLtlTUetAD2JSDSsDIQRLhoJio7aG9YDEaDhAJMZKYlODBmFQDBxtsYjhIxJhgDGLkgBIpXtpDKweRAyUpBwyg4sGmwAEPtAZKW6jf8pKmdLdvZ96bffveN79/NpuG7m6H9377/76Z+WambnZ2NoeQa+W5BAiwEGAhwEIIsBBgIcBCCLAQYCHAQgiwEGAhwEIIsBBgIcBCCLAQYCHAQgiwEGAhwEIIsBBg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