简体   繁体   English

远程安装和调用Pester

[英]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,Pester 新的VSO构建系统的新手,并且试图让Pester在每次签入时运行测试。我已经设置并配置了一个简单的PowerShell脚本,可以在每次签入时运行。

已配置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,以查看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

I tried to use PSGet: 我尝试使用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? 如何远程安装和执行Pester来运行单元测试?

Try this with PsGet: 尝试使用PsGet:

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

Or use Chocolatey : 或使用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. VSO市场中有一项任务可以让您运行Pester单元测试。 The task can be found here at the marketplace . 该任务可以在市场上找到。 You can see the source code at: git Vsts-Build-Pester 您可以在以下位置查看源代码: git Vsts-Build-Pester

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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