Skip to content

Add one-line snippet from failure to provide a context#266

Merged
dlwyatt merged 4 commits intopester:masterfrom
vors:context
Jan 27, 2015
Merged

Add one-line snippet from failure to provide a context#266
dlwyatt merged 4 commits intopester:masterfrom
vors:context

Conversation

@vors
Copy link
Copy Markdown
Member

@vors vors commented Jan 24, 2015

My attempt to implement the behavior described in #265

Comment thread Functions/Assertions/Should.ps1 Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no ConvertTo-Json cmdlet in PowerShell v2.

Comment thread Functions/Assertions/Should.ps1 Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line can go away; nothing else is looking at the ErrorDetails property of ShouldExceptions anymore.

@dlwyatt
Copy link
Copy Markdown
Member

dlwyatt commented Jan 26, 2015

I'm going to merge this into master tomorrow afternoon. (It'll make a good demo of our new parallel test execution CI setup during a conference call.)

@dlwyatt
Copy link
Copy Markdown
Member

dlwyatt commented Jan 26, 2015

Just noticed that this is adding output to non-Should exceptions that shouldn't be there. This modification to Get-PesterResult should take care of that:

    if ($exception.FullyQualifiedErrorID -eq 'PesterAssertionFailed')
    {
        # we use TargetObject to pass structured information about the error.
        $details = $exception.TargetObject

        $failureMessage = $details.message
        $file = $test.File
        $line = $details.line
        $lineText = "`n$line`: $($details.linetext)"
    }
    else {
        $failureMessage = $exception.ToString()
        $file = $Exception.InvocationInfo.ScriptName
        $line = $Exception.InvocationInfo.ScriptLineNumber
        $lineText = ''
    }

    $testResult.failureMessage = $failureMessage -replace "Exception calling", "Assert failed on"
    $testResult.stackTrace = "at line: $line in ${file}${lineText}"

    return $testResult
}

dlwyatt added a commit that referenced this pull request Jan 27, 2015
Add one-line snippet from failure to provide a context
@dlwyatt dlwyatt merged commit 30a9689 into pester:master Jan 27, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants