我如何成功地在克隆GitHub仓库上本地运行Pester单元测试?



我想在将我的更改推回GitHub并初始化拉取请求之前,在本地运行项目的所有Pester单元测试。

到目前为止,我已经克隆了一个项目,xFailOverCluster,并安装了Pester和所有依赖模块(使用build-script找到)。

  • 纠缠5.3.1
  • .build.ps1 -Tasks build
    • 取样器。GitHubTasks
    • DscResources保存。outputRequiredModules
  • .build.ps1
    • DscResource。测试
      • DscResource。分析仪
      • DscxDSCResourceDesigner
      • PSPKI
  • DscResources。常见的

我可以使用提供的.build.ps1脚本成功构建模块。但是提供的纠缠单元测试都将失败。

VS Code中使用更通用的Pester Test Explorer扩展时,我得到同样的失败:

Starting discovery in 7 files.
[-] Discovery in D:UsbReposOnexFailOverCluster.GitHubtestsUnitMSFT_xCluster.Tests.ps1 failed with: System.IO.FileNotFoundException: The specified module 'xFailOverCluster' was not loaded because no valid module file was found in any module directory.
...
Discovery found 0 tests in 643ms.
...

好吧,原来是我的构建有问题(并且需要错误的Pester版本,v4)。

一旦所有的依赖模块都到位了,我就可以运行由build.ps1调用的Pester测试了。
在这个项目中没有办法只运行Invoke-Pester

最新更新