It's a well known problem that arises because Spock can't (via its JUnit facade) tell Eclipse upfront how many test methods will get run, and what their names will be. (In data-driven tests, both of these aspects are dynamic. What gets reported to Eclipse upfront is the same as when @Unroll
isn't used. Eclipse gets confused when correlating this with what gets reported during the test run.)
I can't think of a good way to solve this problem on Spock's side. I've considered approaches such as adding some ugly heuristics or executing tests twice when running inside Eclipse, but none of them were convincing. A more desirable solution would be to improve the Eclipse JUnit plugin to better handle this situation, which can also arise in many other JUnit compatible test frameworks.
If you can't live with the current output, here are some steps you could take:
- File an improvement request in the Eclipse issue tracker, and ask everyone on the Spock forum to vote for it.
- Don't use
@Unroll
. (It only affects reporting, not execution. One reason why it's opt-in is that some IDEs have problems with it.) - Switch to IntelliJ IDEA, which offers significantly better Groovy, JUnit, and Spock support than Eclipse.
- Blame your coworker for introducing Spock. :-)