joke / spock-mockable

Mock the un-mockable
Apache License 2.0
28 stars 2 forks source link

Project with mixed junit and spock issue when upgrading 2.3.0 to 2.3.2 #375

Closed ClaudioConsolmagno closed 1 year ago

ClaudioConsolmagno commented 1 year ago

I have a project which has both junit and spock tests. Spock-mockable is defined as a dependency but isn't actually needed as I realised later. I tried upgrading from 2.3.0 to 2.3.2 and noticed the following: If I run the full build, all tests run and pass successfully. However, If I try to run one of the junit tests individually it fails with a message:

java.lang.IllegalArgumentException: com.foo.bar.MyEnum is not an enum type
    at java.base/java.lang.Class.enumConstantDirectory(Class.java:3578) ~[na:na]
    at java.base/java.lang.Enum.valueOf(Enum.java:234) ~[na:na]
    at org.hibernate.type.descriptor.java.EnumJavaTypeDescriptor.fromName(EnumJavaTypeDescriptor.java:84) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
    at org.hibernate.type.descriptor.java.EnumJavaTypeDescriptor.wrap(EnumJavaTypeDescriptor.java:54) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
    at org.hibernate.type.descriptor.java.EnumJavaTypeDescriptor.wrap(EnumJavaTypeDescriptor.java:16) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]
    at org.hibernate.type.descriptor.sql.VarcharTypeDescriptor$2.doExtract(VarcharTypeDescriptor.java:62) ~[hibernate-core-5.6.15.Final.jar:5.6.15.Final]

This class is 100% a Java enum. Have run this with Java 11 and 17 corretto. This is in a spring boot 2.7 project with spring data jpa, using spock 2.3-groovy-3.0

Going back to version 2.3.0 solves the issue.

joke commented 1 year ago

Hi @ClaudioConsolmagno

could you provide a minimal project example with all the dependencies included. The problem seems a little more complicated.

Unless you have any spock tests where should be no class transformation even if all the transitive dependencies of spock-mockable are included. Consequently no JUnit tests should be affected.

Regards Joke

ClaudioConsolmagno commented 1 year ago

Hi Joke, yeah this would have been pretty complicated to try and find a minimal example. In the end we migrated all junit tests to spock and now version 2.3.2 works fine. I would be ok if you closed this issue and open it back up if anybody else comes across this.

stale[bot] commented 1 year ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.