pester / pester Goto Github PK
View Code? Open in Web Editor NEWPester is the ubiquitous test and mock framework for PowerShell.
Home Page: https://pester.dev/
License: Other
Pester is the ubiquitous test and mock framework for PowerShell.
Home Page: https://pester.dev/
License: Other
would be nice to have the following:
"$TestDrive\file.txt".contents.should.contain("hello")
If I have a powershell build script and I want to call Invoke-Pester
, how can I determine the exit status of the command?
I in change #18 the addition of the -ExitCode
parameter, but when include this parameter it closes my powershell window. Not what I want...
How do I get a handle to the test results of Invoke-Pester
? Something like '$LASTEXITCODE` will do, but even a Powershell object with more test results would be good.
Thoughts?
Caveat: I can't imagine this hasn't been found by others so I suspect I am doing something wrong, however, there seems to be a problem (given my usage) with It.ps1.
If I throw an error in my test (mistakenly or intentionally), it appears that Get-PesterResult fails with the following errors:
Property 'ShouldExceptionLine' cannot be found on this object. Make sure that it exists.
At C:\Chocolatey\lib\pester.2.0.3\tools\Functions\It.ps1:124 char:12
+ if($pester.ShouldExceptionLine) {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], PropertyNotFoundException
+ FullyQualifiedErrorId : PropertyNotFoundStrict
The variable '$line' cannot be retrieved because it has not been set.
At C:\Chocolatey\lib\pester.2.0.3\tools\Functions\It.ps1:131 char:57
+ $failureLine = $test.StartPosition.StartLine + ($line-2)
+ ~~~~~
+ CategoryInfo : InvalidOperation: (line:String) [], RuntimeException
+ FullyQualifiedErrorId : VariableIsUndefined
The variable '$failureLine' cannot be retrieved because it has not been set.
At C:\Chocolatey\lib\pester.2.0.3\tools\Functions\It.ps1:132 char:44
+ $testResult.stackTrace = "at line: $failureLine in $($test.File)"
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (failureLine:String) [], RuntimeException
+ FullyQualifiedErrorId : VariableIsUndefined
I believe the problem is that on occasion (perhaps never?), ShouldExceptionLine is not set. To avoid this I changed the conditional in the if statement from simply
...
if($pester.ShouldExceptionLine) {
$line=$pester.ShouldExceptionLine
$pester.ShouldExceptionLine=$null
}
...
to
...
if($pester.ContainsKey("ShouldExceptionLine") -and $pester.ShouldExceptionLine) {
$line=$pester.ShouldExceptionLine
$pester.ShouldExceptionLine=$null
}
...
I suspect an additional modification would be to set ShouldExceptionLine (possibly in the catch block on line 76 of It.ps1, but I am not certain) as follows:
...
try{
temp
} catch {
$pester.results.FailedTestsCount += 1;
if ($_.Exception | Get-Member Line) { $pester.ShouldExceptionLine = $_.Exception.Line }
$exception = $_;
}
...
I wonder if the problem is due to a Set-StrictMode -Version "Latest" or Set-StrictMode -Version 3 entry, perhaps that is why others haven't noticed this?
Thanks,
Mark
Write script to validate the pester installation and also check whether pester is available in installed modules.
I need ps1 script ouput invoke-pester not installed means return false,otherwise return true
Currently, local variables defined in Pester functions (e.g. $output in It) can be overridden in tests, resulting in erratic and unwanted behaviour.
We need to scope the local variables defined in Pester functions to private.
Need to fiixup mock scoping. Ideally, you should be able to declare mocks global to a describe block within the describe and have all contexts inherit those with the option to override. This can make context "Arrange" sections much more clean. Alas, if there is more than one context, this fails unintuitively.
Testing a function that calls another function called "Cleanup" causes pester to call the dot sourced Cleanup and not its own Cleanup.
Not sure yet how to approach this. Whenever I think I finally understand powershell scoping rules, I am proved wrong. I just want to make sure we look at this because this had me spinning my wheels for quite some time before I realized what was happening.
For example, a test like below, which is supposed to fail, will not fail:
It "adds positive numbers" {
$sum = Add-Numbers 2 3
$sum
$sum.should.be(4)
}
My Powershell prompt gets "@{should=System.Object}" added to it when i run Invoke-Pester.
My test imports a module and calls functions from that. The functions contains Write-Host calls.
Perhaps I just don't know how to accomplish this with the current Mock functionality, but here is an example:
# This function sends an SMTP e-mail.
# Set up the SMTP Connection object.
$SMTPClient = New-Object System.Net.Mail.SMTPClient
$SMTPClient.Host = "smtp.example.com"
# Set up the mail message object.
$MailMessage = New-Object System.Net.Mail.MailMessage
$MailMessage.From = "[email protected]"
$MailMessage.To = "[email protected]"
$MailMessage.Subject = "This is the subject"
$MailMessage.Body = "Example email."
$SMTPClient.Send($MailMessage)
Is there any way to Mock the $SMTPClient.Send($MailMessage) method?
Currently the time measurements are around the It blocks. This is misleading since these are typically very simple comparisons of basic values and the bulk of the time is in the context or describe blocks. I suggest we measure the describes and print the times after each of those.
The line numbers is still out of wack in the latest nuget version (2.0.3). Powershell 3, Windows Server 2008 R2.
bla.Tests.ps1:
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
. "$here\$sut"
Describe "bla" {
It "does something useful" {
Expect-Result $true $false "Stone flied"
}
}
bla.ps1:
# Empty
# Empty
# Empty
# Empty
# Empty
# Empty
# Empty
# Empty
# Empty
# Empty
function Expect-Result($expected, $actual, $text) {
$actual | Should Be $expected
}
run pester, output is:
Executing all tests in C:\Andrew\pp\new-fixture
Describing bla
[-] does something useful 192ms
Expected: {True}, But was {False}
at line: 18 in C:\Andrew\pp\new-fixture\bla.Tests.ps1
Tests completed in 192ms
Passed: 0 Failed: 1
The line number is apparently wrong.
When just starting a new fixture, the assert syntax has some VERY odd behavior. Given an empty function like so:
function Get-AppSetting {
}
The following test PASSES, and clearly should not:
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
. "$here\$sut"
Describe "Get-AppSetting" -tag "WIP" {
$val = Get-AppSetting $config "ClientValidationEnabled"
It "should return the value if present" {
$val | should not benullorempty
}
}
When using the old syntax, the user is not aware they need to run pester with the -EnableLegacyAssertionSyntax. Plus, who wants to use that old syntax nowadays?
When running pester new-feature -Name bla
, the code that is produced uses the legacy should
syntax, and thus throws a error. The built-in help text also is not updated to explain the new syntax and still has it in format $true.should.be
One of the stated intentions of Pester is to output NUnit XML reports. This would be excellent for tying into Continuous Integration builds for visibility on the test coverage and quality of build scripts.
In the docs about Should it describes Have_Count_Of
C:\PS>$actual=@(1,2,3)
C:\PS>$actual | Should Have_Count_Of @(3,2) #Will fail
but when I run that in a test I get.
[-] descriptive text here 155ms
The term 'PesterHave_Count_Of' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
at line: 32 in C:\Code\MyTest.Tests.ps1
Any thoughts?
I just installed Pester and I think it is awesome!
I am relatively new to PowerShell though.
I'm curious - why not make all the function files ".psm1" and use Import-Module in Pester.psm1?
Is it an issue of scope?
Thanks,
Shawn
Current workaround is to [regex]::escape the input string.
Failing test to be provided ;)
I would like to be able to tag describes to run a subset of tests...
I have fast and slow for instance.
Can describe maybe take a param?
I am trying to wrap a text fixture around some code that extends an object with a property. I get an error that appears to be caused by pester.
Has anyone succeeded in writing tests on functions that use properties?
The error I get:
Describing Get-PropertyOfItem
Select-Object : Property cannot be processed because property "should" already exists.
At C:\Repos\ClinicientOps\clinicientops\General\Functions\Get-PropertyOfItem.ps1:4 char:11
+ $files | Select-Object *, @{Name = "TestProperty"; Expression = { $dir.Length}} ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (Windows:PSObject) [Select-Object], PSArgumentException
+ FullyQualifiedErrorId : AlreadyExistingUserSpecifiedPropertyNoExpand,Microsoft.PowerShell.Commands.SelectObjectC
ommand
My function:
function Get-PropertyOfItem {
$dir = "C:\"
$files = Get-ChildItem $dir
$files | Select-Object *, @{Name = "TestProperty"; Expression = { $dir.Length}} -Last 1
}
My test function:
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
. "$here\$sut"
Describe "Get-PropertyOfItem" {
It "does something useful" {
$prop = Get-PropertyOfItem
$prop.TestProperty.should.be(3)
}
}
See SO question about this issue here: http://stackoverflow.com/questions/10540632/is-it-possible-to-include-functions-only-without-executing-the-script
A script such as the following is not we'll suited to be dot sourced in a test fixture because it has mandatory parameters and code not inside of functions that should not be executed but does get executed.
[cmdletbinding()]
param (
[Parameter(Mandatory=$true)]
[string] $MyInput
)
function Show-Input {
param ([string] $Incoming)
Write-Output $Incoming
}
function Save-TheWorld {
#ToDo
}
Write-Host (Show-Input $MyInput)
If a sut already relies on Start-Transcript, executing it in the context of a Pester It function will fail, as Start-Transcript cannot be nested.
Tried to git clone from the repo, and then build. Got failed build with the following error:
Describing Setup
[-] returns a location that is in a temp area 3ms
Expected: {C:\Users\andrewsav\AppData\Local\Temp\pester}, But was {C:\Users\andrewsav\AppData\Local\Temp\pester}
at line: 7 in C:\Scm\pester\Functions\Setup.Tests.ps1
Tested both on Windows 8 and Windows 8.1 On Windows Server 2008R2 with powershell 3 it does not fail. The test script for some reason thinks that $env:Temp never has trailing slash.
When using Should BeNullOrEmpty with Set-StrictMode "Latest" an error results:
Index was outside the bounds of the array.
Thanks,
Mark
Here is an example that will illustrate this:
Describe "A line number mis calculation" {
$someValue = "value"
it "should be 'wrong'" {
$someValue | should be 'wrong'
}
}
The resulting pester failure is:
[-] should be 'value' 101ms
Expected: {wrong}, But was {value}
at line: 49 in C:\dev\boxstarter\tests\pester.tests.ps1
Should be line 5 not 49.
It is possible that a test script invokes code from another file. When an exception is thrown from this another file, the line of code it happened on is reported incorrectly. This is because that the code assumes that it's always in the main test script file. It can be fixed by checking the current script file name and comparing it with the test script file name. I ended up doing something like this:
Start-PesterConsoleTranscript
try{
temp
"[+] $output " | Write-Host -ForegroundColor green;
} catch {
$failure_message = $_.toString() -replace "Exception calling", "Assert failed on"
$results.FailedTests += $name
"[-] $output" | Write-Host -ForegroundColor red
Write-Host -ForegroundColor red $error_margin$failure_message
if ($_.InvocationInfo.ScriptName -eq "$TestDrive\temp.ps1") {
$temp_line_number = $_.InvocationInfo.ScriptLineNumber - 2
$failure_line_number = $start_line_position + $temp_line_number
Write-Host -ForegroundColor red $error_margin"Test script: $test_file"
Write-Host -ForegroundColor red $error_margin"File: $($test_file): at line:$($failure_line_number)"
}
else {
Write-Host -ForegroundColor red $error_margin"Test script: $test_file"
Write-Host -ForegroundColor red $error_margin"File: $($_.InvocationInfo.ScriptName): at line:$($_.InvocationInfo.ScriptLineNumber)"
}
}
Stop-PesterConsoleTranscript
I'm not sure if this is correct but this illustrates the idea.
This test is being ignored because it's returning validation errors. Previously this test was just asserting whether or not Validate-Xml returns $true or not. Since it's actually returning an array of validation errors, this test was passing resulting in a test that was passing when it shouldn't have been.
Could Pester internally be using Microsoft.PowerShell.Utility\Write-Host so we can Mock Write-Host? It's sometimes a little troublesome to create a wrapper function for Write-Host just to overcome this "problem"
So I know I am not the first to ever think or mention this, but having done a deep dive into the Chocolatey testing written by @ferventcoder which uses pester and its own rolled mocks, I now have a picture in my head of how this might look. Something like this:
SYNTAX
Mock [-function <string>] [-mockWith <ScriptBlock>] [-paramFilter [<HashTable>]]
EXAMPLE
Describe "When calling Chocolatey-Install for return value" {
$script:exec_chocolatey_install_actual = $true
$expected='dude'
Mock Chocolatey-Nuget -mockWith { return $expected} -paramFilter @{packageName={$packageName -eq 'testPackage'};version=$Pester.ANY}
$returnv = Chocolatey-Install 'testpackage'
It "should return appropriately" {
$returnv.should.be($expected)
}
It "should return as the type that was passed in" {
$true.should.be($returnv.GetType().Name -eq 'String')
}
}
The example uses one of the tests in Chocolatey. It is testing a function called Chocolatey-Install which in turn calls a function Chocolatey-Nuget. The test does not want the real Chocolatey-Nuget which does alot of internet stuff to actually run. The test just wants Chocolatry-Nuget to return the string 'dude' if Chocolatey-Nuget is called with a package name called 'testPackage'.
This would be implemented by Renaming the function called Chocolatey-Nuget to something else and then dynamically creating a function called Chocolatey-Nuget that invokes the mockWith scriptBlock if the param filters are met. At the end of Describe, all renamed mocked functions are renamed back to their original names.
I'd love to submit a pull request for this but wanted to get a discussion started.
After the System.Object type is extended in the Pester module, you can no longer break out of a loop construct using the break keyword in any code that follows. You receive the following exception:
@{should=System.Object}Invalid character '@', labels can only contain characters, numbers and '_'.
At [break statement location]
+ foreach($num in 1..1) { break <<<< }
...
...
You can reproduce if you modify your Pester.psm1 as follows:
function Invoke-Pester($relative_path = ".", [switch] $EnableExit) {
Reset-GlobalTestResults
. "$PSScriptRoot\ObjectAdaptations\PesterFailure.ps1"
Write-Host "break works"
foreach($num in 1..1) { break }
Update-TypeData -pre "$PSScriptRoot\ObjectAdaptations\types.ps1xml" -ErrorAction SilentlyContinue
Write-Host "break does not work"
foreach($num in 1..1) { break }
$fixtures_path = Resolve-Path $relative_path
Write-Host Executing all tests in $fixtures_path
...
...
The error does not occur until the following line of code is executed:
Update-TypeData -pre "$PSScriptRoot\ObjectAdaptations\types.ps1xml" -ErrorAction SilentlyContinue
I'm still trying to figure out exactly what is causing the problem, but it looks like PowerShell is treating break as a variable (label) and fails when the type extensions execute. Just a guess though.
Found some more information. If you decorate your break statement with a loop label as described in the link below, the error does not appear. Maybe the @ character is being "defaulted" in when no label is specified? At any rate, it looks like Label is being extended with "should."
Need to isolate Pester's overriding of global variables.
Given the following test
It "should not fail" {
{ throw 'helpful error message' } | Should Not Throw
}
I get the following output.
[-] should fail 2ms
Expected: the expression to not throw an exception
at line: 9 in C:\Code\sample\powershellTests\src\run-sample.Tests.ps1
When an exception happens in a test, I would be helpful if we could see the actual exception. Currently the exception information appears to be swallowed and is hiding crucial details that would help us diagnose a failing test.
Similarly if we say "{ something } | Should Throw" I would be great if you could consider a syntax that would allow us to assert more specific information about the error.
Possibly something like
{ throw "hi"; } | Should Throw "hi"
Keeping in mind wild card or regex searches
{ [string]::Format("{0} {1}", "hello") } | Should Throw "*Index (zero based) must be greater than or equal to zero and less than the size of the argument list.*"
Or be able to determine the type of the exception object.
The current url for installing via PsGet is looking at your personal GitHub repo, it has since moved to pester/pester
I supposed a simple submission request to PsGet would fix this?
It would be useful to see on the Readme some instructions on how to get pester easily installed.
Currently I'm cloning the entire repo (new issue to follow) and then leveraging it that way.
I should be able to cinst pester
. (it's up on chocolatey, but out of the gate doesn't appear to install in an easy way for me to leverage)
I would like to see a super-duper-happy-path to "run this, and boom you now have the pester module every time you run powershell" option.
I am trying to leverage pester and given the following steps I a not able to leverage the Should.Be(...)
syntax of a test.
mkdir pester-issue
cd pester-issue
git init
git submodule add https://github.com/pester/Pester.git lib/pester
import-module .\lib\pester\Pester.psm1
New-Fixture src demoFunction
cd .\src
Edit the demoFunction.Tests.ps1 to look like
Describe "demoFunction" {
It "should not fail" {
"Hello".Should.Be("Hello")
}
}
Save the test file and run the tests with the bin/pester.bat
..\lib\pester\bin\pester.bat
I get the following error
You cannot call a method on a null-valued expression.
at line: 12 in C:\Code\personal\pester-issue\src\demoFunction.Tests.ps1
Am I missing something?
Hey!
I came across a problem testing Exceptions.
When testing for exceptions it turns out to be unreliable and broken at some places. I put an example of it below for clarity!
I have 2 Methods:
function ThrowExceptionTest {
$Message = ("This Line should Throw an Exception")
Throw $Message
}
function DoesNotThrow {
}
The tests are:
It "should throw exception" {
ThrowExceptionTest | Should Throw
}
It "should throw exception 2" {
Try {
ThrowExceptionTest
Write-Host -ForegroundColor Magenta "Exception not Thrown"
} Catch
{
Write-Host -ForegroundColor Magenta "Exception Thrown $($_.Exception)"
}
}
It "should not throw Exception 1" {
DoesNotThrow | Should Not Throw
}
It "should not throw Exception 2" {
Try {
DoesNotThrow
Write-Host -ForegroundColor Magenta "Exception not thrown"
} Catch {
Write-Host -ForegroundColor Magenta "Exception $($_.Exception)"
}
}
The Output is:
[W0216 15:16:12 Temp\throw_test]> Invoke-Pester
Executing all tests in C:\Temp\throw_test
Describing ThrowExceptionTest
[-] should throw exception 1ms
This Line should Throw an Exception
at line: 8 in C:\Temp\throw_test\ThrowExceptionTest.Tests.ps1
Exception Thrown System.Exception: This Line should Throw an Exception
[+] should throw exception 2 6ms
[-] should not throw Exception 2ms
Expected: the expression to not throw an exception. Message was {The expression after '&' in a pipeline element produced a obje
ct that was not valid. It must result in a command name, script block or CommandInfo object.}
at line: 25 in C:\Temp\throw_test\ThrowExceptionTest.Tests.ps1
Exception not thrown
[+] should not throw Exception 0ms
Tests completed in 10ms
Passed: 2 Failed: 2
The troubling part is the error message:
Expected: the expression to not throw an exception. Message was {The expression after '&' in a pipeline element produced a obje
ct that was not valid. It must result in a command name, script block or CommandInfo object.}
Thanks,
Michael
PS: I have to admit that I have no clue which calls are valid and which aren't anymore as the documentation seems to be highly outdated and I haven't had the time to look at the SourceCode directly.
Given the following test:
It "can use the Not BeNullOrEmpty assertion" {
$item1 = New-Object PSObject -Property @{Id=1; Name="foo"}
$item2 = New-Object PSObject -Property @{Id=2; Name="bar"}
@($item1, $item2) | Should Not BeNullOrEmpty
}
I get the following output:
[-] can use the Not BeNullOrEmpty assertion 2ms
Expected: value to not be empty
at line: 117 in C:\Projects\Pester2\Functions\Assertions\Should.Tests.ps1
I would like to be able to test code that throws exceptions for known states/conditions.
As per Muc's suggestion, today, my test will have to look like this:
it "should throw some exception" {
$exceptionThrown = $false
try {
Cmd-ThatThrowsCoolException
} catch [My.CoolException] {
$exceptionThrown = $true
}
$exceptionThrown.should.be($true)
}
But sytnax like this is MUCH better:
Context "when the system is in a weird state" {
It -Throws CoolException {
...
}
}
If I have some code in the Context
for setup purposes that fails, it would be great if the project would consider one of the two strategies below:
It
assertion/test with the same exception.Thoughts?
Example:
$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path).Replace(".Tests.", ".")
. "$here\$sut"
Describe "SomeDescribe" {
Context "When some Context runs and an error happens" {
throw "some error during setup"
It "Should report something" {
# This test should not even run (but possibly fail with the error from the context setup)
}
It "Should report something else" {
# This test should not even run (but possibly fail with the error from the context setup)
}
}
}
Maybe
%statements, %functions, %modules?
Specifically, Get-VMGuest, Get-View, and Get-Cluster
I may just not be setting up the hash table correctly.
$GetVMGuest = @(
@{
OSFullName="Windows Server 2008 R2";
Disks=@(
@{
Path="C:\";
Capacity=32209104896;
FreeSpace=4992696320;
},
@{
Path="D:\";
Capacity=322091516565;
FreeSpace=4995656220;
}
)
}
)
$GetView = @(
@{
Config=@{ Tools=@{ ToolsVersion=9113 } }
Guest=@{
ToolsStatus="toolsOk";
IPAddress="192.168.1.1";
HostName="example.example.com";
}
}
)
$GetCluster = @(
@{
Name="EXAMPLE-CLUSTER";
}
)
Mock Get-VMGuest { $GetVMGuest }
Mock Get-View { $GetView }
Mock Get-Cluster { $GetCluster }
The error message:
Get-VMGuest : Cannot process argument transformation on parameter 'VM'. Cannot convert the
"System.Collections.Hashtable" value of type "System.Collections.Hashtable" to type
"VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine[]".
At D:\UserData\aaron\powershell\Functions\CollectVirtualServers.ps1:52 char:38
+ $guest = Get-VMGuest $_
+ ~~
+ CategoryInfo : InvalidData: (:) [Get-VMGuest], ParameterBindingArgumentTransfo
rmationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-VMGuest
Get-View : Cannot process argument transformation on parameter 'VIObject'. Cannot convert the
"System.Collections.Hashtable" value of type "System.Collections.Hashtable" to type
"VMware.VimAutomation.Sdk.Types.V1.VIObject[]".
At D:\UserData\aaron\powershell\Functions\CollectVirtualServers.ps1:57 char:44
+ $view = Get-View -VIObject $_
+ ~~
+ CategoryInfo : InvalidData: (:) [Get-View], ParameterBindingArgumentTransforma
tionException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-View
Get-Cluster : Cannot process argument transformation on parameter 'VM'. Cannot convert the
"System.Collections.Hashtable" value of type "System.Collections.Hashtable" to type
"VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine[]".
At D:\UserData\aaron\powershell\Functions\CollectVirtualServers.ps1:63 char:44
+ $cluster = Get-Cluster -VM $_
+ ~~
+ CategoryInfo : InvalidData: (:) [Get-Cluster], ParameterBindingArgumentTransfo
rmationException
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-Cluster
The strange part is, I've mocked Connect-VIServer and Get-VM in the same test, and it seems to have no problems.
Not sure if it's related or not, but I'm also having to dot-source a certain function every time before I call Invoke-Pester or the session forgets it.
If you open a PS command-line, import Pester and invoke it on a set of valid tests, it will run the tests to correctly but close the window when the run is done. This behavior can be by commenting out the exit $failedTestCount line in the Exit-WithCode function of TestResults.
It would be helpful if the auto-generated fixtures produces something more like:
It "does something useful" {
$expectedValue = $true
$returnedValue = $false
$returnedValue | Should Be $expectedValue
}
This is similar to Matt Wrock's tutorial here: http://www.mattwrock.com/post/2012/11/15/Unit-Testing-Powershell-and-Hello-Pester.aspx
$result = Invoke-Pester
$result.NumberOfTests
$result.NumberOfFailures
...
I'm guessing the template breaks when the path param contains .\
Tempted to wrap tests around the Create-Fixture.ps1 script to describe the functionality that it contains.
There are some parts missing from the wiki as regards to examples and some things I think are wrong. Would it be an idea to go through the wiki and make it look better?
I can help out with some parts that I know of.
Windows 8 and PS 3 don't have .net 3 installed by default.
Change the PesterFailure.ps1 file not use a specific .net version. I assume specifying just -language CSharp runs on whatever framework is currently the powershell host.
So changing
Add-Type -language CSharpVersion3 @'
to
Add-Type -language CSharp @'
worked fine for me on Windows 8 without .net 3 installed, not sure if this breaks other platforms or not.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.