spockframework / spockframework/spock
Cannot declare multiple variables in single line inside setup block
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 483
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I can't seem to define, without initializing, multiple variables in one line inside a when or a setup block.
Example:
import spock.lang.Specification
class exampleSpec extends Specification {
def "foo"() {
when:
def a, b
a = 0
b = 1
then:
a != b
}
}
This fails when accessing b:
No such property: b for class: ....
Moving the declaration outside the block works.
I am using:
Groovy Version: 2.4.3 JVM: 1.8.0_45 Vendor: Oracle Corporation OS: Linux
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 with the provided Spock specification and compare multiple-variable declarations inside the when and setup blocks with declarations outside those blocks. Investigate how Spock handles block-local variables, using the reported No such property: b failure as the expected behavior to reproduce; done means the example can access both variables and the regression is covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy, java
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100