簡體   English   中英

遠程安裝和調用Pester

[英]Install and invoke Pester remotely

我是PowerShell,Pester 新的VSO構建系統的新手,並且試圖讓Pester在每次簽入時運行測試。我已經設置並配置了一個簡單的PowerShell腳本,可以在每次簽入時運行。

已配置PowerShell

我首先簡單地嘗試了Invoke-Pester,以查看VSO團隊是否已經設想了這一點並建立了通​​用的單元測試框架,但是我得到了以下可預測的結果:

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

我嘗試使用PSGet:

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

但這也不起作用:

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

如何遠程安裝和執行Pester來運行單元測試?

嘗試使用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

VSO市場中有一項任務可以讓您運行Pester單元測試。 該任務可以在市場上找到。 您可以在以下位置查看源代碼: git Vsts-Build-Pester

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM