-
-
Notifications
You must be signed in to change notification settings - Fork 473
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strange error when running pester with a function that calls Start-Process #353
Comments
Thanks for reporting the issue. Could you please share code+test example that does not work for you? That way we can run it on our systems and determine what is wrong, without much guessing. Btw I don't see any double spaces there. The markdown probably stripped them for you. |
Source Files; Test Files; The script under test is Start-Neo4jShell The current test file has a Powershell Version IF around it. You'll need to remove that if for the error to occur. |
Repro for pester#353 in PowerShell 2.0. I wasn't able to reproduce this using a function for some reason, but mocking Start-Process does cause the error to occur. Incidentally, it's being caused by this line in MockPrototype: [object] $ArgumentList = Get-Variable -Name args -ValueOnly -Scope Local -ErrorAction $IgnoreErrorPreference It appears to be a problem when the mocked command also has an -ArgumentList parameter, which contains Validation attributes such as ValidateNotNullOrEmpty() (though why I wasn't able to reproduce this with a mocked function instead of Start-Process, I don't know.)
$ArgumentList variable renamed to something that's extremely unlikely to conflict with an actual parameter name.
I am trying to write unit tests for a function which eventually calls Start-Process. I've written a series of Pester tests that work fine in Powershell 4.0 and 3.0 but in 2.0 I get some strange behaviour.
Setup;
Windows 8.1 64bit - PS 4.0, .Net 4.5.1
Pester 3.3.8
Function under test - This function is in a module;
I am not even Mocking the the Start-Process function but I received the error;
The variable cannot be validated because the value is not a valid value for the ArgumentList variable.
Note the double space in between 'value' and 's'. It's like Pester is mucking up the value being passed but I don't see how. All Mocks are within the context scope
Things I've tried but made no difference;
-ArgumentList @()
gave the following error message;[-] Error occurred in Context block 118ms Cannot validate argument on parameter 'ArgumentList'. The argument is null, empty, or an element of the argument collection contains a null value. Supply a collection that does not contain any null values and then try the command again.
This error is expectedFor the moment I'm just going to avoid those tests on PS 2.0 but any help with this issue would be great.
The text was updated successfully, but these errors were encountered: