簡體   English   中英

Pester的Invoke-Pester居住在哪里?

[英]Where does Pester's Invoke-Pester reside?

根據本文檔 ,應該可以使用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

閱讀此文檔后 ,很明顯,在運行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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM