spockframework / spockframework/spock
Provide block label in failure output
Open
Nobody has claimed this yet.
component:core
enhancement
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 483
- PR merge metrics
- No merged PRs in 30d
Description
It would be great to see the block label belonging to the failing assertion. Below added the new line beginning with the word Context:
Context: 'there are still three elements'
Condition not satisfied:
numbers.size() == 2
| | |
| 3 false
[1, 2, 3]
Expected :2
Actual :3
With that it would be easier to understand the context of the failure message without looking at the code.
Sample feature for the failure above:
def "test set modification"() {
given: 'a set with three element'
Set numbers = [1, 2, 3]
when: 'adding an existing element'
numbers.add(2)
then: 'there are still three elements'
numbers.size() == 2
}
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 locating the failure output generated for the sample Groovy feature and its failing assertion. Reproduce the shown output, then verify that the assertion's block label appears as Context while the existing condition, expected, and actual sections remain intact.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy, java
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100