Skip to content

Problem matcher skips some failed tests #1291

Closed
@Glober777

Description

@Glober777

Issue Type: Bug

I've noticed that not all the test failures that are reported by Pester show up in Problems list. For example, I have the following script (Invoke-SomeCustomOperation.ps1):

function Invoke-SomeCustomOperation {
    [CmdletBinding()]
    param ($A, $B)

    Write-Output ($A * $B)
}

Here's how the Invoke-SomeCustomOperation.Tests.ps1 file looks like:

$here = Split-Path -Parent $MyInvocation.MyCommand.Path
$sut = (Split-Path -Leaf $MyInvocation.MyCommand.Path) -replace '\.Tests\.', '.'
. "$here\$sut"

Describe "Invoke-SomeCustomOperation" {
    It "Sums two numbers just fine" {
        Invoke-SomeCustomOperation -A 2 -B 3 | Should -Be 7
    }

    It "Errors out if one of the provided parameters is not a number" {
        {Invoke-SomeCustomOperation -A 2 -B 'B' | Should -Be 3} | Should -Throw
    }

    It "Having fun" {
        Throw "Some exception"
    }
}

Just in case, here's what I have in tasks.json:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    // Show the output window always
    "presentation": {
        "echo": true,
        "reveal": "always",
        "focus": false,
        "panel": "dedicated"
    },
    
    "tasks": [
        {
            "label": "Test",
            "type": "shell",
            "command": "Invoke-Pester -PesterOption @{IncludeVSCodeMarker=$true}",
            "group": {
                "kind": "test",
                "isDefault": true
            },
            "problemMatcher": [
                "$pester"
            ]
        }
    ]
}

Here's the screenshot of the VSCode with Test run:
image

Here's the Problems list:
image

The expected result is that apart from tagging the Having Fun test, it should also tag Sums two number just fine.

Attached is the project that I used for repro:
Pester.zip

Pester module details:

PS C:\> Get-Module -ListAvailable Pester


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     4.3.1      Pester                              {Describe, Context, It, Should...}
Script     4.1.1      Pester                              {Describe, Context, It, Should...}
Script     4.0.8      Pester                              {Describe, Context, It, Should...}
Script     4.0.3      Pester                              {Describe, Context, It, Should...}
Script     4.0.2      Pester                              {Describe, Context, It, Should...}
Script     3.4.0      Pester                              {Describe, Context, It, Should...}


    Directory: C:\Program Files (x86)\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     3.4.0      Pester                              {Describe, Context, It, Should...}


PS C:\>

Extension version: 1.6.0
VS Code version: Code 1.22.2 (3aeede733d9a3098f7b4bdc1f66b63b0f48c1ef9, 2018-04-12T16:38:45.278Z)
OS version: Windows_NT x64 10.0.16299

System Info
Item Value
CPUs Intel(R) Core(TM) i5-6300U CPU @ 2.40GHz (4 x 2496)
Memory (System) 7.88GB (1.28GB free)
Process Argv C:\Program Files\Microsoft VS Code\Code.exe
Screen Reader no
VM 0%

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions