-
Notifications
You must be signed in to change notification settings - Fork 468
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
Defining responses for additionalInterfaces
doesn't work
#1405
Comments
AndreasTu
added a commit
to AndreasTu/spock
that referenced
this issue
Jul 31, 2023
The metaClass used in JavaMocks of Groovy classes did not contain the methods of additionalInterfaces, so the fix is to change the MetaClass, if we are a GroovyObject and have additionalInterfaces to the mocked MetaClass. It is not the best solution, because we now use the MetaClass of the Mock, which also contains methods and interfaces of Spock internal, but there is currently no class implementing mockType + additionalInterfaces. This would be a bigger rework. The second fix is for the JavaMock of a Java class with additionalInterfaces. Previously the mockType of the Java class was used also for the methods of the additionalInterfaces, which lead to a NullPointerException. This fixes spockframework#1405
The PR #1730 should resolve this issue. |
AndreasTu
added a commit
to AndreasTu/spock
that referenced
this issue
Aug 3, 2023
The metaClass used in JavaMocks of Groovy classes did not contain the methods of additionalInterfaces, so the fix is to change the MetaClass, if we are a GroovyObject and have additionalInterfaces to the mocked MetaClass. It is not the best solution, because we now use the MetaClass of the Mock, which also contains methods and interfaces of Spock internal, but there is currently no class implementing mockType + additionalInterfaces. This would be a bigger rework. The second fix is for the JavaMock of a Java class with additionalInterfaces. Previously the mockType of the Java class was used also for the methods of the additionalInterfaces, which lead to a NullPointerException. This fixes spockframework#1405
AndreasTu
added a commit
to AndreasTu/spock
that referenced
this issue
Aug 7, 2023
The metaClass used in JavaMocks of Groovy classes did not contain the methods of additionalInterfaces, so the fix is to change the MetaClass, if we are a GroovyObject and have additionalInterfaces to the mocked MetaClass. It is not the best solution, because we now use the MetaClass of the Mock, which also contains methods and interfaces of Spock internal, but there is currently no class implementing mockType + additionalInterfaces. This would be a bigger rework. Moved the metaClass field down to BaseMockInterceptor to use it in both cases: GroovyMockInterceptor and JavaMockInterceptor The second fix is for the JavaMock of a Java class with additionalInterfaces. Previously the mockType of the Java class was used also for the methods of the additionalInterfaces, which lead to a NullPointerException. This fixes spockframework#1405
AndreasTu
added a commit
to AndreasTu/spock
that referenced
this issue
Aug 11, 2023
The metaClass used in JavaMocks of Groovy classes did not contain the methods of additionalInterfaces, so the fix is to change the MetaClass, if we are a GroovyObject and have additionalInterfaces to the mocked MetaClass. It is not the best solution, because we now use the MetaClass of the Mock, which also contains methods and interfaces of Spock internal, but there is currently no class implementing mockType + additionalInterfaces. This would be a bigger rework. Moved the metaClass field down to BaseMockInterceptor to use it in both cases: GroovyMockInterceptor and JavaMockInterceptor The second fix is for the JavaMock of a Java class with additionalInterfaces. Previously the mockType of the Java class was used also for the methods of the additionalInterfaces, which lead to a NullPointerException. This fixes spockframework#1405
AndreasTu
added a commit
to AndreasTu/spock
that referenced
this issue
Aug 21, 2023
The metaClass used in JavaMocks of Groovy classes did not contain the methods of additionalInterfaces, so the fix is to change the MetaClass, if we are a GroovyObject and have additionalInterfaces to the mocked MetaClass. It is not the best solution, because we now use the MetaClass of the Mock, which also contains methods and interfaces of Spock internal, but there is currently no class implementing mockType + additionalInterfaces. This would be a bigger rework. Moved the metaClass field down to BaseMockInterceptor to use it in both cases: GroovyMockInterceptor and JavaMockInterceptor The second fix is for the JavaMock of a Java class with additionalInterfaces. Previously the mockType of the Java class was used also for the methods of the additionalInterfaces, which lead to a NullPointerException. This fixes spockframework#1405
AndreasTu
added a commit
to AndreasTu/spock
that referenced
this issue
Aug 25, 2023
The metaClass used in JavaMocks of Groovy classes did not contain the methods of additionalInterfaces, so the fix is to change the MetaClass, if we are a GroovyObject and have additionalInterfaces to the mocked MetaClass. It is not the best solution, because we now use the MetaClass of the Mock, which also contains methods and interfaces of Spock internal, but there is currently no class implementing mockType + additionalInterfaces. This would be a bigger rework. Moved the metaClass field down to BaseMockInterceptor to use it in both cases: GroovyMockInterceptor and JavaMockInterceptor The second fix is for the JavaMock of a Java class with additionalInterfaces. Previously the mockType of the Java class was used also for the methods of the additionalInterfaces, which lead to a NullPointerException. This fixes spockframework#1405
AndreasTu
added a commit
to AndreasTu/spock
that referenced
this issue
Sep 15, 2023
The metaClass used in JavaMocks of Groovy classes did not contain the methods of additionalInterfaces, so the fix is to change the MetaClass, if we are a GroovyObject and have additionalInterfaces to the mocked MetaClass. It is not the best solution, because we now use the MetaClass of the Mock, which also contains methods and interfaces of Spock internal, but there is currently no class implementing mockType + additionalInterfaces. This would be a bigger rework. Moved the metaClass field down to BaseMockInterceptor to use it in both cases: GroovyMockInterceptor and JavaMockInterceptor The second fix is for the JavaMock of a Java class with additionalInterfaces. Previously the mockType of the Java class was used also for the methods of the additionalInterfaces, which lead to a NullPointerException. This fixes spockframework#1405
AndreasTu
added a commit
to AndreasTu/spock
that referenced
this issue
Oct 1, 2023
The metaClass used in JavaMocks of Groovy classes did not contain the methods of additionalInterfaces, so the fix is to change the MetaClass, if we are a GroovyObject and have additionalInterfaces to the mocked MetaClass. It is not the best solution, because we now use the MetaClass of the Mock, which also contains methods and interfaces of Spock internal, but there is currently no class implementing mockType + additionalInterfaces. This would be a bigger rework. Moved the metaClass field down to BaseMockInterceptor to use it in both cases: GroovyMockInterceptor and JavaMockInterceptor The second fix is for the JavaMock of a Java class with additionalInterfaces. Previously the mockType of the Java class was used also for the methods of the additionalInterfaces, which lead to a NullPointerException. This fixes spockframework#1405
leonard84
added a commit
that referenced
this issue
Oct 3, 2023
The metaClass used in JavaMocks of Groovy classes did not contain the methods of additionalInterfaces, so the fix is to change the MetaClass, if we are a GroovyObject and have additionalInterfaces to the mocked MetaClass. It is not the best solution, because we now use the MetaClass of the Mock, which also contains methods and interfaces of Spock internal, but there is currently no class implementing mockType + additionalInterfaces. This would be a bigger rework. The second fix is for the JavaMock of a Java class with additionalInterfaces. Previously the mockType of the Java class was used also for the methods of the additionalInterfaces, which lead to a NullPointerException. This fixes #1405 Co-authored-by: Leonard Brünings <leonard.bruenings@gradle.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Describe the bug
There is some additional context here. Check the reproduction for explanation what the bug is.
cc @leonard84
To Reproduce
Expected behavior
To print
true
,2
andclass B
.Actual behavior
Prints
true
andclass java.lang.Object
.Java version
openjdk version "17.0.1" 2021-10-19
OpenJDK Runtime Environment (build 17.0.1+12)
OpenJDK 64-Bit Server VM (build 17.0.1+12, mixed mode)
Buildtool version
Gradle 7.3.3
Build time: 2021-12-22 22:43:07 UTC
Revision:
Kotlin: 1.5.31
Groovy: 3.0.9
Ant: Apache Ant(TM) version 1.10.11 compiled on July 10 2021
JVM: 17.0.1 (Oracle Corporation 17.0.1+12)
OS: Linux 5.15.10-arch1-1 amd64
What operating system are you using
Linux
Dependencies
Spock is the only dependency. Any version (including
2.1-M2
).Additional context
No response
The text was updated successfully, but these errors were encountered: