8000 Chained Shoulds only fail when the last Should in the chain fails · Issue #5 · jonwagner/PShould · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Chained Shoulds only fail when the last Should in the chain fails #5
Closed
@cmurczek

Description

@cmurczek

Hi,
I ran into an issue with chained assertions. Apparently the test only fails when the last Should in the chain fails:

TestScope "ChainedAssertions" {
    Describing "and" {
        Given "There are chained assertions"{

            It "fails on the first failed assertion"{
                @('a','b','c') | Should Count 2 and | Should Contain 'b' -test
            }

            It "fails on the last failed assertion"{
                @('a','b','c') | Should Count 3 and | Should Contain 'z' -test
            }
        }
    }
}

This seems to be caused by $result being overwritten each time the Should method is executed. As a quickfix the if(!$result) statement at the end of the Should function would need to be evaluated before chaining.
The nicer fix would be to allow $result to hold multiple values, one for each should. This would allow executing all assertions, while the quickfix only reveals one bug at a time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0