spockframework / spockframework/spock

PollingConditions.eventually should work also if defined with def

Open
#1,054 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
3.6k
Forks
483
PR merge metrics
No merged PRs in 30d

Description

Hi, in the below's example I've provided two tests:
first is going to pass, second is going to fail

The only difference is the way of creating PollingConditions object

class Playground extends Specification {

    def "not boom"() {
        given:
        def conditions = new PollingConditions()

        when:
        def x = 10

        then:
        conditions.eventually {
            1 == 2
        }
    }

    def "boom 2"() {
        given:
        PollingConditions conditions = new PollingConditions()

        when:
        def x = 10

        then:
        conditions.eventually {
            1 == 2
        }
    }
}

Is it expected behavior? There is nothing about it in the documentation of @ConditionBlock, which I strongly believe is related to that (we don't need to write assert keyword in the clojure).

If it's related to groovy itself it might be a good idea to fail when such usage is detected.

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 reproducing the two examples using PollingConditions and compare how @ConditionBlock handles the def-created and explicitly typed variables. Read the PollingConditions and @ConditionBlock entry points, then determine the expected behavior and capture it with a regression test; the issue is done when the behavior is corrected or clearly documented, including any invalid usage.

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
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.