Invoke-pester When Powershell file test is in a Function seems to not locate any tests #2156
Replies: 2 comments 1 reply
-
I have worked around my issue, I just remove the function from the first script that contained the tests. Just had make some changes in azure to support how that script/function was being called. It still would be good to know why invoke-pester cannot call a script which has its tests in a function |
Beta Was this translation helpful? Give feedback.
-
Calling the functions pesterstart.tests.ps1 to start the tests does not have issue. Its just that the script that is passed into invoke-pester cannot have a powershell function. I removed the function and just used params to get the data into the test script |
Beta Was this translation helpful? Give feedback.
-
I have been reading and reading but just cannot pin point an answer to my issue or lack of knowledge.
Issue Outline:
When calling my tests with pester everything runs but no tests are ever found. I have dug around to find out that If the *.test.ps1 file being called is inside a powershell Function nothing is found. The moment I remove the function everything works as expected.
Here is a cut back version of my test sample:
Calling the invoke-pester
===========
PesterStart.Test.ps1 file:
This will run but I get the following:
Starting discovery in 1 files. Discovery found 0 tests in 62ms. Running tests. Tests completed in 60ms Tests Passed: 0, Failed: 0, Skipped: 0 NotRun: 0
Now if I change PesterStart.Test.ps1 file to:
My output is
Any ideas :)
Beta Was this translation helpful? Give feedback.
All reactions