spockframework / spockframework/spock
Spock fails with insufficient invocation count when route cause was underneath exception
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 483
- PR merge metrics
- No merged PRs in 30d
Description
Assuming we use groovy and assuming we have such service method:
method(input){
Long val = Optional.ofNullable(input).map(Integer::longValue).orElse(doesntmatter);
return otherService.something(val);
}
Also assuming we expect that second service Mock will be invoked once (1 * otherService...).
When passing Long as "input" parameter i would expect exception:
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer
But what i get is failed invocation count for otherService shadowing underneath exception.
Removing count check results in correct behaviour - exception being properly handled.
For me it looks like Spock completely ignores underneath exceptions in case of failed invocation count checks.
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 a minimal Groovy specification using an interaction count check and the service method described in the issue, then inspect how failed invocation counts and underlying exceptions are handled. Done means the ClassCastException is reported instead of being hidden by the insufficient invocation count failure.
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