[英]Where does Pester's Invoke-Pester reside?
According to this documentation it should be possible to measure code coverage using Pester. 根据本文档 ,应该可以使用Pester测量代码覆盖率。
PS C:\path\to\codeCoverage> Invoke-Pester .\CoverageTest.Tests.ps1 -CodeCoverage .\CoverageTest.ps1
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 line:1 char:1
+ Invoke-Pester .\CoverageTest.Tests.ps1 -CodeCoverage .\CoverageTest.ps1
+ ~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Invoke-Pester:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
After reading this documentation it was clear that the Pester module needs to be imported before running Invoke-Pester
阅读此文档后 ,很明显,在运行Invoke-Pester
之前需要导入Pester模块。
PS C:\path\to\codeCoverage> Import-Module "C:\ProgramData\Chocolatey\lib\pester.3.1.1\tools\Pester.psm1"
PS C:\path\to\codeCoverage> Invoke-Pester .\CoverageTest.Tests.ps1 -CodeCoverage .\CoverageTest.ps1
Executing all tests in 'C:\Users\r\Desktop\codeCoverage\CoverageTest.Tests.ps1'
Describing Demonstrating Code Coverage
[+] Calls FunctionOne with no switch parameter set 1.8s
[+] Calls FunctionTwo 287ms
Tests completed in 2.09s
Passed: 2 Failed: 0 Skipped: 0 Pending: 0
Code coverage report:
Covered 60.00 % of 5 analyzed commands in 1 file.
Missed commands:
File Function Line Command
---- -------- ---- -------
CoverageTest.ps1 FunctionOne 5 return 'SwitchParam was set'
CoverageTest.ps1 FunctionTwo 16 return 'I do not'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.