Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameterized Tests don't get marked as Inconclusive when empty #833

Closed
RemcoKapinga opened this issue Aug 25, 2017 · 9 comments
Closed
Labels

Comments

@RemcoKapinga
Copy link

When using an empty parameterized test, the test does not get marked as 'Inconclusive'. It does get marked as 'Passed'.

Describe 'Defect: Parameterized Tests do not get marked as Inconclusive when empty.' {

    BeforeAll {
        $testCases = @{ Name = 'a' }
    }

    It 'will mark an empty test method as Inconclusive' {

    }

    It 'will mark an empty parameterized test method as Inconclusive' -TestCases $testCases {
        param($Name)

    }
}

Results in:

Executing script .\Empty.tests.ps1

  Describing Defect: Parameterized Tests do not get marked as Inconclusive when empty.
    [?] will mark an empty test method as Inconclusive 31ms
    [+] will mark an empty parameterized test method as Inconclusive 11ms
Tests completed in 42ms
Tests Passed: 1, Failed: 0, Skipped: 0, Pending: 1, Inconclusive: 0

It would be expected that a parameterized test case is evaluated in the same way as a normal test case.

@nohwnd nohwnd added this to the v4.1 milestone Aug 25, 2017
@nohwnd nohwnd added the Bug label Aug 25, 2017
@it-praktyk
Copy link
Contributor

@Remco-74, IMHO, it's strictly related to #826. I think that a one of these should not be processed.

@nohwnd, are you agree?

@nohwnd
Copy link
Member

nohwnd commented Aug 25, 2017

We should keep both.

@it-praktyk
Copy link
Contributor

OK, thx for a clarification.

@RemcoKapinga
Copy link
Author

Correct, these are two diffrent issues.

I could not locate the code that marks testcases inconclusive when empty, otherwise i could try to submit a pr. Can anyone point me in the right direction?

@nohwnd
Copy link
Member

nohwnd commented Aug 25, 2017

@Remco-74 Sure here it is.

@RemcoKapinga
Copy link
Author

RemcoKapinga commented Aug 25, 2017

Not a PR, but here's a patch.

I've changed the detetion of an empty test to the following (using the Ast of the scriptblock):

#mark empty Its as Pending
#[String]::IsNullOrWhitespace is not available in .NET version used with PowerShell 2
$testIsEmpty = 
    [String]::IsNullOrEmpty($test.Ast.BeginBlock.Statements) -and 
    [String]::IsNullOrEmpty($test.Ast.ProcessBlock.Statements) -and 
    [String]::IsNullOrEmpty($test.Ast.EndBlock.Statements)

if ($PSCmdlet.ParameterSetName -eq 'Normal' -and $testIsEmpty)
{
    $Pending = $true
}

using the following tests (positive and negative):

Describe 'Defect: Parameterized Tests do not get marked as Inconclusive when empty.' {

    BeforeAll {
        $testCases = @{ Name = 'a' }
    }

    It 'will mark an empty test method as Inconclusive' {
        # i am empty
    }

    It 'will mark an empty parameterized test method as Inconclusive' -TestCases $testCases {
        param($Name)
        # i am empty
    }

    It 'will not mark a not empty test method as Inconclusive' {
        Write-Verbose 'i am not empty'
    }

    It 'will not mark a not empty parameterized test method as Inconclusive' -TestCases $testCases {
        param($Name)
        Write-Verbose 'i am not empty'
    }
}

delivers the following (desired) results:

Executing all tests in .\Empty.tests.ps1

Executing script .\Empty.tests.ps1

  Describing Defect: Parameterized Tests do not get marked as Inconclusive when empty.
    [?] will mark an empty test method as Inconclusive 35ms
    [?] will mark an empty parameterized test method as Inconclusive 7ms
    [+] will not mark a not empty test method as Inconclusive 8ms
    [+] will not mark a not empty parameterized test method as Inconclusive 9ms
Tests completed in 61ms
Tests Passed: 2, Failed: 0, Skipped: 0, Pending: 2, Inconclusive: 0

@nohwnd
Copy link
Member

nohwnd commented Aug 25, 2017

Hmm, could you post a PR or it really does not permit you to do that?

@RemcoKapinga
Copy link
Author

I created a PR (is my first), I hope this works!

@nohwnd
Copy link
Member

nohwnd commented May 6, 2018

The related PR was merged a year ago, closing this.

@nohwnd nohwnd closed this as completed May 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants