Comments (4)
Hm, strange. This happens in AppVeyor, Contains and Not Contains doesn't seem to work.
I run now a Windows container and only install poshspec and in this container it works.
PS C:\projects> .\test.ps1
Describing Files
[+] File 'test.txt' Should Exist 478ms
[-] File 'test.txt' Should Not Exist 217ms
Expected: C:\projects\test.txt to not exist, but it was found
1: 'C:\projects\test.txt' | Should Not Exist
at <ScriptBlock>, <No file>: line 1
at <ScriptBlock>, C:\Program Files\WindowsPowerShell\Modules\Poshspec\2.2.1\Private\Invoke-PoshspecExpression.ps1: line 13
[+] File 'test.txt' Should Contain 'hello' 176ms
[-] File 'test.txt' Should Contain 'other' 75ms
Expected: file C:\projects\test.txt to contain {other}
1: 'C:\projects\test.txt' | Should Contain 'other'
at <ScriptBlock>, <No file>: line 1
at <ScriptBlock>, C:\Program Files\WindowsPowerShell\Modules\Poshspec\2.2.1\Private\Invoke-PoshspecExpression.ps1: line 13
PS C:\projects> get-module
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Binary 1.0.0.0 CimCmdlets {Export-BinaryMiLog, Get-CimAssociatedInstance, Get-CimClass, Get-CimInsta...
Manifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Manifest 3.0.0.0 Microsoft.PowerShell.Security {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-Authentico...
Manifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Manifest 3.0.0.0 Microsoft.WSMan.Management {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, Enable-WSManCredSS...
Binary 1.0.0.1 PackageManagement {Find-Package, Find-PackageProvider, Get-Package, Get-PackageProvider...}
Script 3.4.0 Pester {AfterAll, AfterEach, Assert-MockCalled, Assert-VerifiableMocks...}
Script 2.2.1 Poshspec {AppPool, AuditPolicy, CimObject, DnsHost...}
Script 1.0.0.1 PowerShellGet {Find-Command, Find-DscResource, Find-Module, Find-RoleCapability...}
Script 1.2 PSReadline {Get-PSReadlineKeyHandler, Get-PSReadlineOption, Remove-PSReadlineKeyHandl...
Any tips what might be the problem in AppVeyor environment?
The other Pester version, AppVeyor seems to have 4.3.1 installed.
from poshspec.
It seems to behave different between running it like .\test.ps1
and powershell -File .\test.ps1
. The Contains rules behave different in AppVeyor.
Any advisory how to run it predictable in AppVeyor builds?
from poshspec.
PoshSpec is just a Pester abstraction. The Contains
assertion was removed in Pester (I don't remember which version). If you use Invoke-Pester
against your test file you get all of Pester's functionality: -Exit
, -PassTrue
, -OutputXml
, etc.
Does that help?
from poshspec.
Thanks @cdhunt
After some hours "learning the hard way" I solved my problems.
Integrating Pester based things looks hard if you come from Serverspec and used to Linux commands exiting properly. :-)
I have it running using $lastExitCode in our appveyor caller script and Invoke-Pester
in the test script that sets up the environment and runs the test.
I first thought I can use $ErrorActionPreference = 'Stop'
in one or both of the scripts, but that didn't work. So that was my learning curve to dig deeper into the world of PowerShell and Pester.
from poshspec.
Related Issues (20)
- Unable to call Custom functions in poshspec.
- Http tests don't work against https URLs with invalid certs HOT 4
- Additional Test: AuditPolicy
- Additional Test: LocalUser
- Additional Test: UserRightsAssignment
- Additional Private Function: Test-RunAsAdmin
- Service Function: Get-Service vs Get-WmiObject\Get-CimInstance HOT 1
- Pester 4.x support - Allow for new syntax HOT 2
- Documentation Transition HOT 3
- CHANGELOG HOT 1
- Poshspec Pester Tests broken from PR #44 HOT 1
- more efficient method for package checking HOT 1
- Path prompt with SoftwareProduct HOT 9
- PowerShell Gallery shows Pester functions in this module HOT 1
- Update Wiki HOT 2
- Unable to test PowerShell Auditing Settings via registry HOT 2
- Cannot bind argument to parameter 'Command' because it is null. HOT 1
- Compatibility with latest versions of pester
- Issues
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 poshspec.