spockframework / spockframework/spock

Provide block label in failure output

Open
#923 0 comments 2 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.