简体   繁体   English

从Sublime Text运行PowerShell Pester测试的有效方法

[英]Efficient way to run PowerShell Pester tests from Sublime Text

I'm using Sublime Text (ST) to create my PowerShell scripts, Pester to test them. 我正在使用Sublime Text(ST)创建我的PowerShell脚本,使用Pester对其进行测试。

To run test script, one must to switch to that tab, then press CTRL + B . 要运行测试脚本,必须切换到该选项卡,然后按CTRL + B。 This process must be repeated for each test script. 必须对每个测试脚本重复此过程。

Is there an easy way to Sublime Text to run all of the tests in the project's directory? 有没有一种简便的方法可以让Sublime Text运行项目目录中的所有测试?

Is there a way to have these test automatically run when a script or test changes (similar to guard )? 有没有一种方法可以在脚本或测试更改时自动运行这些测试(类似于guard )?

I added a script named Tests.ps1 to the project's directory with a single instruction: 我通过一条指令将名为Tests.ps1的脚本添加到了项目目录中:

Invoke-Pester

To run all tests, I open this file and press Ctrl + B . 要运行所有测试,我打开此文件,然后按Ctrl + B。

** edit ** **编辑**

Created a new build system named 'Pester'. 创建了一个名为“ Pester”的新构建系统。 The contents of Pester.sublimebuild : Pester.sublimebuild的内容:

{
    "cmd": ["powershell.exe", "-noprofile", "Invoke-Pester"],
    "selector": "source.powershell"
}

To run all tests, press Ctrl + B . 要运行所有测试,请按Ctrl + B。

If this doesn't work automatically, assign Pester as the build system using Tools | Build System | Pester 如果不能自动运行,请使用“ Tools | Build System | Pester将Pester分配为构建系统Tools | Build System | Pester Tools | Build System | Pester Tools | Build System | Pester and try again. Tools | Build System | Pester然后重试。

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

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