ParameterBindingValidationException: Cannot bind argument to parameter 'Path' because it is null. #2396
-
Hi I am converting a data-driven test from Pester 4 to 5. It verifies that files produced by my script has none of the known tokens present in their content. My test worked in Pester 4, but now I can't get them to work. The test fails with a series of "ParameterBindingValidationException: Cannot bind argument to parameter 'Path' because it is null." - one error per token I'm looking for. The problem seems to be about the test script input parameter ($TestRoot), which I pass in from the test harness and its used to pass to teh -Path property of Get-ChildItem. What's "funny" is my test harness actually runs to test scripts and one works (pass TestRoot as data) the other fails. And I verify in both scripts via "BeforeDiscovery" that TestRoot has a value - its output twice successfully in the console window. The failing one is the data driven test. I am hoping someone can spot the problem, because i have not been successful so far: but I wonder from the error message if "Path" is not about what is passed to Test file that fails:
Test file that succeeds:
Test harness (execution):
Output:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Tip: I'd recommend moving |
Beta Was this translation helpful? Give feedback.
$fullName
is undefined. You need to store the variable using aBeforeAll
block like you've done with$token
.Tip: I'd recommend moving
$allFiles = ...
and$tokens = ..
inside aBeforeDiscovery
-block. Just cosmetic, but shows intent and that it's not forgotten v4-code.