简体   繁体   中英

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.

To run test script, one must to switch to that tab, then press 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?

Is there a way to have these test automatically run when a script or test changes (similar to guard )?

I added a script named Tests.ps1 to the project's directory with a single instruction:

Invoke-Pester

To run all tests, I open this file and press Ctrl + B .

** edit **

Created a new build system named 'Pester'. The contents of Pester.sublimebuild :

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

To run all tests, press Ctrl + B .

If this doesn't work automatically, assign Pester as the build system using Tools | Build System | Pester Tools | Build System | Pester Tools | Build System | Pester and try again.

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