简体   繁体   中英

Install and invoke Pester remotely

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

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?

Try this with PsGet:

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

Or use Chocolatey :

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

There is a task in the VSO marketplace that lets you run your Pester unit tests. The task can be found here at the marketplace . You can see the source code at: git Vsts-Build-Pester

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM