spockframework / spockframework/spock
Expectations on named parameters not wrapped with Map literal give compilation error
Open
Nobody has claimed this yet.
Module-Core
Type-Defect
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 483
- PR merge metrics
- No merged PRs in 30d
Description
Originally reported on Google Code with ID 358
Mocked collaborator. Expectation set on a method with named parameters. Named parameters
must be wrapped with Map literal (although not required by Groovy). If not, compilation
error occurs.
Doesn't work:
1 * collaborator.method(param1: 1, param2: 2)
Compilation error compiling [unit] tests: unknown kind of argument list: org.codehaus.groovy.ast.expr.TupleExpression@1066d85f[org.codehaus.groovy.ast.expr.NamedArgumentListExpression@50074d62[org.codehaus.groovy.ast.expr.MapEntryExpression@f6985fa(key:
ConstantExpression[param1], value: ConstantExpression[1]), org.codehaus.groovy.ast.expr.MapEntryExpression@58dae7fd(key:
ConstantExpression[param2], value: ConstantExpression[2])]] (Use --stacktrace to see
the full trace)
Works:
1 * collaborator.method([param1: 1, param2: 2])
Please see the attached test case for the full source code.
Reported by mgryszko on 2014-04-07 14:14:22
- _Attachment: [ExpectationsOnNamedParametersSpec.groovy](https://storage.googleapis.com/google-code-attachments/spock/issue-358/comment-0/ExpectationsOnNamedParametersSpec.groovy)_
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 attached ExpectationsOnNamedParametersSpec.groovy test case and reproduce the compilation error for unwrapped named parameters. Trace the expectation argument handling from that failing example; done means the unwrapped syntax compiles and behaves like the Map-wrapped form.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy, java
- Domain
- compilers, testing-qa
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100