Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Currently trying to use a pester configuration and container. However when using the container the filters (tags) are ignored.

Any advice?

You must be logged in to vote

Thanks for verifying.

🤦‍♂️after I reviewed my code and I had mistakenly removed a character from the variable name of filters applied.

Replies: 1 comment · 4 replies

Comment options

Hi. Can you please provide a sample test file with the necessary tags and the command used to run Pester so we can reproduce?

You must be logged in to vote
4 replies
@kingspider
Comment options

I've thrown together some sample code of how I've tried to implement the tests. Could be some errors, sorry

Suite.Tests.ps1

param (
   [Parameter(Mandatory)]
   [string] $name
)

Describe "Dynamic Test" {

   Context "Test Suite" {

       It "Should Pass"  -Tag 'Pass' {
           $name | Should -be "Pass"
       }

       It "Should fail" -Tag 'Fail' {
           $name | Should -be "Fail"
       }
   }
}

Run.ps1

# import module before creating the object
Import-Module Pester

$container = New-PesterContainer -Path '$PSScriptRoot/*' -Data @{ name = "Pass"  }

# get default from static property
$configuration = [PesterConfiguration]::Default

$configuration.Run.Path = '$PSScriptRoot/*'
$configuration.Run.Container = $container

$configuration.Filter.Tag = 'Pass'
$configuration.Filter.ExcludeTag = 'Fail'

Invoke-Pester -Configuration $configuration
@fflaten
Comment options

You need to replace the single quotes with double quotes in both your Path values so $PSScriptRoot can be resolved. Except for that, this works on my machine.

❯ .\Run.ps1

Starting discovery in 1 files.
Discovery found 2 tests in 153ms.
Running tests.
[+] C:\Users\Frode\Desktop\Demo\Suite\Suite.Tests.ps1 895ms (128ms|629ms)
Tests completed in 913ms
Tests Passed: 1, Failed: 0, Skipped: 0, Inconclusive: 0, NotRun: 1

Only one of the tests was executed. If you add $configuration.Output.Verbosity = 'Detailed' you'll see that it was only "Should Pass" that was executed

What error/result do you get that indicates a problem?

@kingspider
Comment options

Thanks for verifying.

🤦‍♂️after I reviewed my code and I had mistakenly removed a character from the variable name of filters applied.

Answer selected by fflaten
@fflaten
Comment options

Glad it got resolved. Thanks for using Pester!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.