Octopus.Script exported 2018-10-25 by yakuramori belongs to ‘xUnit’ category.
Run xUnit tests with dotnet and vstest and some filters.
Parameters
When steps based on the template are included in a project’s deployment process, the parameters below can be set.
Package directory path
PackageDirectoryPath =
Path to directory with test package
Test package(s)
TestPackages =
Provide test file(s) here. Accepted .dll or .exe. Separate multiple test file names by spaces.
Test case filter
TestCaseFilter =
Only tests that match the given expression will be executed. Separate filter conditions with pipe.
xUnit Additional Parameters
XUnitAdditionalParameters =
Pass any additional parameters you like here, they will be added to dotNet vstest command
Script body
Steps based on this template will execute the following PowerShell script.
Write-Output "Running xUnit tests with dotnet and vstest..."
$dotNetVer = dotnet --version
Write-Output "DotNet version: $dotNetVer"
$dirPath = $PackageDirectoryPath
$testFiles = $TestPackages
$testFilter = $TestCaseFilter
$xUnitAdditionalParams = $XUnitAdditionalParameters
If(-Not $dirPath){
Write-Output "Directory with tests is missing!"
exit 1
}
If(-Not $testFiles){
Write-Output "Test Package(s) missing!"
exit 1
}
Write-Output "Execute test package(s): $testFiles"
Write-Output "With following filter(s): $testFilter"
Write-Output "From Package Directory: $dirPath"
cd $dirPath
If($testFilter){
$runxUnit = "dotnet vstest $testFiles --testcasefilter:'($testFilter)'"
Write-Output "Run xUnit with filter $testFilter"
} Else {
$runxUnit = "dotnet vstest $testFiles"
}
if($xUnitAdditionalParams){
$runxUnit = $runxUnit + " " + $xUnitAdditionalParams
Write-Output "Run xUnit with Additional Params $xUnitAdditionalParams"
}
Write-Output "Run xUnit with command: $runxUnit"
iex $runxUnit
$xunitExit = $lastExitCode
exit $xunitExit
Provided under the Apache License version 2.0.
To use this template in Octopus Deploy, copy the JSON below and paste it into the Library → Step templates → Import dialog.
{
"Id": "f70a5c02-f6c0-40d4-a59a-7157cb2c2dc8",
"Name": "Execute xUnit Tests",
"Description": "Run xUnit tests with dotnet and vstest and some filters.",
"Version": 2,
"ExportedAt": "2018-10-25T10:33:18.672Z",
"ActionType": "Octopus.Script",
"Author": "yakuramori",
"Parameters": [
{
"Id": "ffd652f9-7186-44a7-9d16-63dcb30bd044",
"Name": "PackageDirectoryPath",
"Label": "Package directory path",
"HelpText": "Path to directory with test package",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
},
"Links": {}
},
{
"Id": "fd5ae46f-1b5b-45bb-bf34-605351eeedea",
"Name": "TestPackages",
"Label": "Test package(s)",
"HelpText": "Provide test file(s) here. Accepted .dll or .exe.\nSeparate multiple test file names by spaces.",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
},
"Links": {}
},
{
"Id": "f4630f67-3309-49cf-8fbd-51bcb4b040c8",
"Name": "TestCaseFilter",
"Label": "Test case filter",
"HelpText": "Only tests that match the given expression will be executed. \nSeparate filter conditions with pipe.",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
},
"Links": {}
},
{
"Id": "74312a1f-f6ba-4518-a475-f308b545f398",
"Name": "XUnitAdditionalParameters",
"Label": "xUnit Additional Parameters",
"HelpText": "Pass any additional parameters you like here, they will be added to dotNet vstest command",
"DefaultValue": "",
"DisplaySettings": {
"Octopus.ControlType": "SingleLineText"
},
"Links": {}
}
],
"Properties": {
"Octopus.Action.Script.ScriptSource": "Inline",
"Octopus.Action.Script.Syntax": "PowerShell",
"Octopus.Action.Script.ScriptBody": "Write-Output \"Running xUnit tests with dotnet and vstest...\"\n$dotNetVer = dotnet --version\nWrite-Output \"DotNet version: $dotNetVer\"\n$dirPath = $PackageDirectoryPath\n$testFiles = $TestPackages\n$testFilter = $TestCaseFilter\n$xUnitAdditionalParams = $XUnitAdditionalParameters\n\nIf(-Not $dirPath){\n Write-Output \"Directory with tests is missing!\"\n exit 1\n}\n\nIf(-Not $testFiles){\n Write-Output \"Test Package(s) missing!\"\n exit 1\n}\n\nWrite-Output \"Execute test package(s): $testFiles\"\nWrite-Output \"With following filter(s): $testFilter\"\nWrite-Output \"From Package Directory: $dirPath\"\n\ncd $dirPath\n\nIf($testFilter){\n\t$runxUnit = \"dotnet vstest $testFiles --testcasefilter:'($testFilter)'\"\n Write-Output \"Run xUnit with filter $testFilter\"\n } Else {\n $runxUnit = \"dotnet vstest $testFiles\" \n }\n\nif($xUnitAdditionalParams){\n\t$runxUnit = $runxUnit + \" \" + $xUnitAdditionalParams\n\tWrite-Output \"Run xUnit with Additional Params $xUnitAdditionalParams\"\n}\n\nWrite-Output \"Run xUnit with command: $runxUnit\"\n\niex $runxUnit\n\n$xunitExit = $lastExitCode\n\nexit $xunitExit"
},
"Category": "xUnit",
"HistoryUrl": "https://github.com/OctopusDeploy/Library/commits/master/step-templates//opt/buildagent/work/75443764cd38076d/step-templates/run-xunit.json",
"Website": "/step-templates/f70a5c02-f6c0-40d4-a59a-7157cb2c2dc8",
"Logo": "iVBORw0KGgoAAAANSUhEUgAAAEYAAABXCAIAAAA2xqTtAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAABFHSURBVHhe7drbj93VdQfwuZ+5eGY8trn7ImxDkMAy9KmlDqoovUh9SBukhlcHIYWE/6DEbRWeUglH6nPbx6T9B4J6DVKQClXbJAKlEhKlBAz4NvczM+cyp5/f+U424/GMOSckagd5ydpee++111rftdbev/37zRnsdDoDny8a2vr/c0S3Ie0Hug1pP9BtSPuBdoG0ubnZarUwi4uLZQTlCba+vo5vNpvpRtKgrvHwWaItlNnyDGy326W7vLyMiUJUr9eLwNraGt7gysqKcYwuSUYjlpGdVKm5keiicavT6QAW83SxkcE77rhjYmKC6tXV1eBBeK3BRqMRpjtcUXRGD8pU5MPEYwJTU1NHjx6lM7YWFhbKKmqDH21sbPBnu5+FdoEUsqCs58H169fDJ3JjY2PDw8O1Wk38Mk6YWIFneXElpJsRLUkC+BIRI1ANDg4ODVWF88ADDxhPaJigPJhDRhKUPiCxSl3xIKoTFfYYHh0djXlkKsLxkjHdeLDdZLSFieSHH36onZ+f7w5XJRS1mJGRESGLKlPRo6U24cBn8GbafS/Fv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CbYuc7kro3hPWxRyzyryZLrzN9AnZ1SIPcuoKONW6ho0xW/jsvfQQw/JlakihmEmNvBIRWkzu50MErN2q98dKZGF55FHHklEEJ2p4fBafIClvZlu/058P9BtSPuBbkPaD3Qb0n6gPiB5gnkget552DUaHnMDnfZAu7nZajQ7HpXtZrvV8GLabrZWlpYH3Eu8UnUGNja6V+aKHVipr7Y22/551FJoIfnOpvfTOqbZblhkPO+/bEUMFaYX6jtLbkNulp7crmNQDY9UX+uN88B9wtV/eHRofHxys91ZXVlrt6p3IdechvtHuzU1OcXl4aHq/Rdy7w+NenVLGK/V4HRLaA1UFxRXfktc7aIZnrwm9kh9Qxpy39hsTY7XNta881ZfxsHjzenTp9988ycSUt3b1tZOnjx56dIl78GjI8Nra6u12qirTKvdWFla+K+f/vT48eOvvfaaMAwLwNDo0uLK8NDoyMjYhW/+mdcW9y+3PgxgFApKTPdIfUNylaz+G6o+0k9Mjl+7epVhvrobiqVcuVBPz1R/P79y5crm5sBave4murG+PiYpwyNzB+cefPDBn/3Pe0888UR9dfXUqVNvvfmml4iL37n4h1/+MuV//MxXXn755cOHDwNDG1OKorLYO8l7j8SAC6fXnEZ9eX1lsbW+Jl1i71+zsX7q5PHXfviDVtvNsrrXnjhx/7+98SPzraZLdHNjvb60tLC6uryxodJcPBudVrvTbN195I6f/OjHVy9fc2n94b++PjA49L2/+9tyoy0XcKYz0gv1l6XqbabVHp2oPf3009/61p8L5Pe++93ffPxxl24z8QCpfi+ngM0vLP3a2Uf/8uJ3JscnTxw//qcXLlQKms0zZ8688v3v33fffZacffTs888/78J94cKFK9evv/rqq94jo03+MagwPVGc6IWEylm1sni106o31pbOPvzQz/77nS/+xq9fuXxpYf7Kg184+fobrzWadcfXemPj9ANfeP2N/2xsbB6amf6D3/3tTmvjn/7xlbmDM1cuf7S0OH/61P0//vf/kOD77rz371/5B4wsrDXpbb5/6QO28oIoNMnPrzBLaOrAAaeYsP313/yVXSHAs91fINs84qpI7CWMBJKRqFP3n3zxxRfV2m998QmvjG+99db0zIzZ5cWl9ZUVa+++++7FxSXnvINkdHTk3nvudbrcddddyg8SFrV9ZalvSIpAZp1C4gFA+S517NixfAlx+jl/P/jgg4cfftjLtipykAx2f/1t1kmwtLjoNHOmWQUb17t//hhcra/F8fLFi0JgfuUn3uL8vNbm+cbXX3j77bdfeuklTjupHnvssRdeeMGDmB8XL1585plnDHLowEz1M0mvyoMj1R8w1dLM7KzD8Oxjj3oEJQ+12tjy8urU5MTmL+N1tG9Is3OHB4aGv3r+2SeffHLuyOGvfePrX/rSH3m8fPNPXpyojXd/xD78g3/+l7/49rePHJoBBrD56rMEONU3wPramrNbx245eGju937/d86de/z8+a9OT0+trNaH+jkF9qI+XtS7e6/tFrS+Wp+cnm5tNDtDg6NjY56tasNzaXxCmB0h1SWoVpvYWG8NdDbHJ4bcMFwmhrpf5OgBrC1pm9WvUOgxsrK8Oj41OSCL3Rh/Rlz9Quqsr61OTk254IyNTXhOKZ7q495Qp16vfhNkl8tArVZdiBwivGs2GpudVm18XI1VO3BgYHWlXhvtfgr3jN7YWFhaqn71Njy00WqOjoz+H0CSJacCPB4v7gPG9W392jie09WPdtfXWlMHJl1UV1bWDkxPLC1X17bF5aXZmdmFxYWZA9Vn58FKU3XZcXLobnj4djojY2MjnxVR/5A44ZiySebnFznnsuIuUGVg2BV2RPaEv7NZbaGJ8anh0YHFpeWZmQMWuphqq2ts987qfqQUcY129eMoYJqt5vDI6PAvcAjfSH2vlyJe1evrc3PBUx1ZdpRBp/NYrcbHoeHuz04GvWkMzM5WPwZ3EosC19e7f4MBe1Clra83N9uWeI6qz1TdZ6c+srRf6JcSl/9fdBvSfqDbkPYDfe4gDQz8L61G2lnvHiBSAAAAAElFTkSuQmCC",
"$Meta": {
"Type": "ActionTemplate"
}
}
Page updated on Thursday, October 25, 2018