多个test cases已编写用于使用 Pester 测试新的 Chocolatey 函数。如何检查是否所有分支都被覆盖?
最佳答案
当前版本的 Pester (3.0) 确实支持代码覆盖率。
简单地使用
Invoke-Pester -CodeCoverage *.ps1
获得代码覆盖率(覆盖率%)的完整关系以及测试期间未执行的所有代码行(分支)的摘要:
Tests completed in 10.11s
Passed: 66 Failed: 0 Skipped: 0 Pending: 0
Code coverage report:
Covered 99,20 % of 501 analyzed commands in 22 files.
Missed commands:
File Function Line Command
---- -------- ---- -------
Set-ProgressColor.ps1 Set-ProgressColor 19 Write-Verbose "Progress colors are only supported on the PowerShell com...
关于code-coverage - 如何使用 Pester 获取所有分支的代码覆盖率?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24664565/