简体   繁体   中英

How do I successfully run Pester Unit tests locally on a cloned GitHub repo?

I would like to run all Pester Unit tests locally for a project before pushing my changes back up to GitHub and initializing a Pull Request.

So far I've cloned a project, xFailOverCluster , and installed Pester and all dependent modules (found using the build-script).

  • Pester 5.3.1
  • .\build.ps1 -Tasks build
    • Sampler.GitHubTasks
    • Saved DscResources.Common to \output\RequiredModules
  • .\build.ps1
    • DscResource.Test
      • DscResource.Analyzer
      • DscxDSCResourceDesigner
      • PSPKI
  • DscResources.Common

I can successfully build the module, using the provided .\build.ps1 script. But the provided Pester Unit tests will all fail.

And when using the more generic Pester Test Explorer extension in VS Code , I get the same kind of failures:

Starting discovery in 7 files.
[-] Discovery in D:\UsbRepos\One\xFailOverCluster.GitHub\tests\Unit\MSFT_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.
...

Ok, turns out it was the build that was at fault on my end (and wrong version of Pester, v4 needed).

Once all dependency modules was in place, I was able to run the Pester tests as invoked by the build.ps1 .
No way of just running Invoke-Pester though in this project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM