Install and invoke Pester remotely

时间:2015-06-30 13:52:50

标签: powershell continuous-integration azure-devops pester

I'm new to PowerShell, Pester and the new VSO build system and I'm trying to get Pester to run my tests for each check in. I've set up and configured a simple PowerShell script to run on each check in.

PowerShell Configured

I first tried simply Invoke-Pester to see if the VSO team had envisioned this and set up common unit test frameworks, but I go the following predictable result:

Invoke-Pester : The term 'Invoke-Pester' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At C:\a\64df1c11\Operations Tools\powershell\runPowershellTests.ps1:1 char:1
+ Invoke-Pester
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Invoke-Pester:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

I tried to use PSGet:

(new-object Net.WebClient).DownloadString("http://psget.net/GetPsGet.ps1") | iex
install-module Pester
Invoke-Pester

But that isn't working either:

New-Item : Access to the path 'PsGet' is denied.
At line:17 char:5
+ New-Item -Path ($Destination + "\PsGet\") -ItemType Directory -Force | Out-N ...

How can I remotely install and execute Pester to run my unit tests?

2 个答案:

答案 0 :(得分:1)

尝试使用PsGet:

(new-object Net.WebClient).DownloadString("http://psget.net/GetPsGet.ps1") | iex
Install-Module Pester -Global

或使用Chocolatey

iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
choco install pester

答案 1 :(得分:0)

VSO市场中有一项任务可以让您运行Pester单元测试。可以找到here at the marketplace任务。您可以在以下位置查看源代码:git Vsts-Build-Pester