Comments (3)
Add:
Text of my script
''''
Set-StrictMode -version 2.0
Describe "Test Set-StrictMode" {
It "Test it" {
$true | Should Be $true
}
}
''''
Run "invoke-pester myScript.tests.ps1"
and :
Describing Test Set-StrictMode
The variable '$PesterException' cannot be retrieved because it has not been set.
At C:\Users\aayuhanov\Documents\WindowsPowerShell\Modules\Pester\Functions\It.ps1:89 char:60
-
$pester.testResult = Get-PesterResult $pester.ThisTest $PesterException
-
~~~~~~~~~~~~~~~~
- CategoryInfo : InvalidOperation: (PesterException:String) [], RuntimeException
- FullyQualifiedErrorId : VariableIsUndefined
Property 'testResult' cannot be found on this object. Make sure that it exists.
At C:\Users\aayuhanov\Documents\WindowsPowerShell\Modules\Pester\Functions\It.ps1:90 char:5
-
$pester.results.CurrentDescribe.Tests += $pester.testResult
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
- FullyQualifiedErrorId : PropertyNotFoundStrict
Property 'testResult' cannot be found on this object. Make sure that it exists.
At C:\Users\aayuhanov\Documents\WindowsPowerShell\Modules\Pester\Functions\It.ps1:108 char:8
-
if($pester.testResult.success) {
-
~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
- FullyQualifiedErrorId : PropertyNotFoundStrict
Tests completed in 0ms
Passed: 1 Failed: 0
from pester.
PowerShell 2.0 and 3.0 compatibility is sort of in an unknown state right now :-(
I'm currently getting a Windows VM sorted out so I can take a look at this. Thanks for the sample code and output, that'll help in figuring this out.
from pester.
I'm also having this problem with Set-StrictMode.
Initially I was using PS 2.0 and hit this page with Google. I need my scripts to be PS 2.0 compatible, but it's no problem for me to use PS 4.0 for testing.
Unfortunately it doesn't work on PS 4.0 either.
With this test code, offered by artbear:
Set-StrictMode -version "latest"
Describe "Test Set-StrictMode" {
It "Test it" {
$true | Should Be $true
}
}
I get the following output:
Executing all tests in C:\temp
Describing Test Set-StrictMode
The variable '$PesterException' cannot be retrieved because it has not been set.
At C:\Temp\pester\Functions\It.ps1:78 char:67
+ $Result = Get-PesterResult -Test $Test -Time $time -Exception $PesterExcepti ...
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (PesterException:String) [], RuntimeException
+ FullyQualifiedErrorId : VariableIsUndefined
The variable '$Result' cannot be retrieved because it has not been set.
At C:\Temp\pester\Functions\It.ps1:79 char:27
+ $Pester.AddTestResult($Result.name, $Result.Success, $result.time, $result.f ...
+ ~~~~~~~
+ CategoryInfo : InvalidOperation: (Result:String) [], RuntimeException
+ FullyQualifiedErrorId : VariableIsUndefined
Index was outside the bounds of the array.
At C:\Temp\pester\Functions\It.ps1:80 char:5
+ $Pester.testresult[-1] | Write-PesterResult
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (:) [], IndexOutOfRangeException
+ FullyQualifiedErrorId : System.IndexOutOfRangeException
Tests completed in 0ms
Passed: 0 Failed: 0
PowerShell version is 4.0, Pester version is 2.0.4 (March 9, 2014)
from pester.
Related Issues (20)
- Select-Object and New-MockObject - Discarded PSObject HOT 2
- Mock CommandNotFoundException: Could not find Command Invoke-Sqlcmd HOT 4
- Bring back 'InconclusiveCount' property (or alternative) on returned Pester.Run object HOT 19
- Iām not a developer I run a nonprofit and a Pester Power Shell is running HOT 2
- Pester stopped working in vscode HOT 1
- v5.5 $____Pester.CurrentTest not populated in AfterEach HOT 4
- Missing timestamp from test suite attributes in junit xml export HOT 1
- Unbound container scriptblock unexpectedly runs in Pester scope HOT 10
- Pester 5.5 reports incorrect Skipped results for Pending and Inconclusive HOT 3
- BeOfType doesn't see types, loaded from a file with classes, but the "It" function - does HOT 3
- Refer to a script in a parent directory HOT 2
- Does somthing like @afterstep exist for Pester 4.6 with Invoke Gherkin HOT 1
- New-RandomTempRegistry: Test-Path : No more data is available HOT 2
- Provide a way to more easily modify a mocked parameter before comparing with a test value. HOT 3
- Error during handling of output-element within Write-NUnit3OutputElement HOT 1
- SkipRemainingOnFailure does not function correctly when there are nested BeforeAll blocks HOT 4
- Support shuffling / randomized test runs HOT 7
- Templates in test names do not expand variables when skipped HOT 8
- Add test count to minimal view HOT 4
- Remove -Pending from Set-ItResult HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pester.