-
Notifications
You must be signed in to change notification settings - Fork 466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Method parameter injection into fixture methods is broken in 2.0 #1305
Comments
Vampire
added a commit
to Vampire/spock
that referenced
this issue
Mar 26, 2021
Vampire
changed the title
Method parameter injection is broken in 2.0
Method parameter injection into fixture methods is broken in 2.0
Mar 26, 2021
No further information needed, thank you. |
Nice, thanks a lot! |
leonard84
pushed a commit
that referenced
this issue
Mar 27, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Issue description
Gradle 7 will be available soon and relies on Groovy 3. As a maintainer of gradle-node-plugin, I tried to see if the project will build using Gradle 7.0-rc1. The plugin tests are based on Spock and there was a Groovy version conflict. It sounds like the only way to get the build work is to upgrade Spock to the 2.0 latest milestone. That's what I did and I encountered this issue.
We created an extension to run the integration tests against multiple Gradle versions. For that, we run each spec multiple times and use parameter injection to get the version available. This extension works as expected using Spock 1.3.
But when I upgrade to Spock 2, it no longer works. I saw that the
arguments
arrays now has the right size, whereas in the 1.x version it could be smaller and we had to enlarge it.The problem is that the
arguments
array is empty whereas mysetup
method has one parameter that should be injected. For this reason, if I set the first argument to the value I want to inject, I get ajava.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
error.If I try to enlarge the
arguments
array as it was necessary in previous versions, I get ajava.lang.IllegalArgumentException: length of arguments array must not change from 0 to 1
.MethodInvocation
does not let me set one argument since the method has no arguments (which is wrong).It sounds like the cause of the issue is that the
MethodInvocation
contains some wrong information.How to reproduce
I created a GitHub project that shows this issue. Run
./gradlew build
to execute it.Additional Environment information
Java/JDK
Groovy version
3.0.7
Build tool version
Gradle
6.8.3
Operating System
Ubuntu 20.04
IDE
IntelliJ
Build-tool dependencies used
Gradle/Grails
testImplementation("org.spockframework:spock-core:2.0-M4-groovy-3.0")
Hope this will help to solve this issue. Feel free to ask me further information if needed. Thanks a lot for your work!
The text was updated successfully, but these errors were encountered: