我正在使用版本纠缠版本 5.1.0
我创建了一个简单的 test.psm1
function testScript { write-host 'hello' }
我创建了一个纠缠文件让我们称之为 test-tests.ps1
Describe "test" {
Context "test call" {
Import-Module .\test.psm1
Mock -ModuleName 'test' testScript { write-host 'hello3' }
testScript
}
}
当我运行它时,它会返回“你好”。对于我的生活,我无法理解为什么 Pester 不会使用 testScript 的 Mock 版本并返回“hello3”。任何人都看到我在纠缠时哪里出错了?