spockframework / spockframework/spock
Spock assertion inside if-statement doesn't work
Open
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 483
- PR merge metrics
- No merged PRs in 30d
Description
See this blog post for a thorough analysis of the issue.
Given test case:
def "should fail on expected == result comparison"() {
given:
def expected = "Hello, John!"
when:
def result = "Hello, Joe!"
then:
if (expected) {
expected == result
}
}
Expected result: FAIL
Actual result: PASS
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided Groovy specification with the conditional assertion, then trace Spock's handling of assertions inside if-statements. Done means the example fails when expected and result differ, with a regression test covering the conditional case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100