pester / vscode-adapter

Run PowerShell Pester Tests with Visual Studio Code
MIT License
58 stars 13 forks source link

Nested Context can cause tests results to display incorrectly #196

Open kevball2 opened 1 year ago

kevball2 commented 1 year ago

Nest contexts don't appear to display results correctly in the test explorer pane.

BeforeDiscovery {
    $testCases = @(
        @{  
            Name = "fizz"
        },
        @{
            Name = "buzz"
        },
        @{  
            Name = "foo"
        },
        @{
            Name = "bar"
        }
    )
}

Describe "Testing Policy Definition <name>" -ForEach $testCases {   
    Context 'Level 1' {
        It 'Should not be null level 1' {
            $name | should -Not -BeNullOrEmpty
        }
        Context "Level 2" {
            It 'Should be 3 characters or greater' {
                $name.length | should -BeGreaterOrEqual  3
            }
        }
    }
}

The output in the test pane does not show the expect results though

image

The pester output shows that the level 2 context tests are showing as "Test Moved or Changed" on each run.

2023-09-07 07:53:57.336 [info] Test Run Start: 1 test items
2023-09-07 07:53:57.642 [info] Test Discovery Start: 1 files
2023-09-07 07:53:57.756 [info] Discovery: Test Moved Or Changed - C:\USERS\<USER>\GIT\PESTER-TESTING\PESTER.TESTS.PS1>>TESTING POLICY DEFINITION <NAME>>>LEVEL 1>>LEVEL 2>>SHOULD BE 3 CHARACTERS OR GREATER
2023-09-07 07:53:57.763 [info] Discovery: Test Moved Or Changed - C:\USERS\<USER>\GIT\PESTER-TESTING\PESTER.TESTS.PS1>>TESTING POLICY DEFINITION <NAME>>>LEVEL 1>>LEVEL 2>>SHOULD BE 3 CHARACTERS OR GREATER
2023-09-07 07:53:57.775 [info] Discovery: Test Moved Or Changed - C:\USERS\<USER>\GIT\PESTER-TESTING\PESTER.TESTS.PS1>>TESTING POLICY DEFINITION <NAME>>>LEVEL 1>>LEVEL 2>>SHOULD BE 3 CHARACTERS OR GREATER
2023-09-07 07:53:57.787 [info] Discovery: Test Moved Or Changed - C:\USERS\<USER>\GIT\PESTER-TESTING\PESTER.TESTS.PS1>>TESTING POLICY DEFINITION <NAME>>>LEVEL 1>>LEVEL 2>>SHOULD BE 3 CHARACTERS OR GREATER
2023-09-07 07:53:57.797 [info] Discovery Run End (PesterInterface stream closed)
2023-09-07 07:53:58.489 [info] Test Run End: PesterInterface stream closed

In the test results pane it does show the correct number of tests was run

Starting discovery in 1 files.
Discovery found 8 tests in 47ms.
Running tests.
[+] C:\Users\<user>\git\pester-testing\pester.tests.ps1
 566ms (81ms|453ms)
Tests completed in 580ms
Tests Passed: 8,
Failed: 0,
Skipped: 0

NotRun: 0
JustinGrote commented 1 year ago

THe <name> is not resolving in the test change info, maybe there's an order issue with resolving that.

kevball2 commented 1 year ago

THe <name> is not resolving in the test change info, maybe there's an order issue with resolving that.

Is there more info I can gather to help sort this issue? Sadly I am not any good at TypeScript or JavaScript or I would take a look at the source