thymeleaf-testing
thymeleaf-testing copied to clipboard
Support for Mockito 4
With Mockito 4, the deprecated org.mockito.Matchers has been removed in favour of org.mockito.ArgumentMatchers.
Hence, the latest version fails with a ClassNotFoundException.
I encountered this, while upgrading to Spring Boot 2.6.
stack trace:
java.lang.NoClassDefFoundError: org/mockito/Matchers
at org.thymeleaf.testing.templateengine.context.web.WebProcessingContextBuilder.createMockServletContext(WebProcessingContextBuilder.java:275)
at org.thymeleaf.testing.templateengine.context.web.WebProcessingContextBuilder.build(WebProcessingContextBuilder.java:144)
at org.thymeleaf.testing.templateengine.engine.TestExecutor.executeTest(TestExecutor.java:392)
at org.thymeleaf.testing.templateengine.engine.TestExecutor.executeTestable(TestExecutor.java:256)
at org.thymeleaf.testing.templateengine.engine.TestExecutor.executeSequence(TestExecutor.java:279)
at org.thymeleaf.testing.templateengine.engine.TestExecutor.executeTestable(TestExecutor.java:250)
at org.thymeleaf.testing.templateengine.engine.TestExecutor.execute(TestExecutor.java:235)
at org.thymeleaf.testing.templateengine.engine.TestExecutor.execute(TestExecutor.java:204)
...
Caused by: java.lang.ClassNotFoundException: org.mockito.Matchers
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
... 78 more
will this actually be solved with https://github.com/thymeleaf/thymeleaf-testing/pull/22? I see that mockito 4 is there as dependency..
yes and no. It will only upgrade version 4. version 3 should stay untouched. v4 will be incompatible with the current spring build as it will work with Spring 6.
mh, so testing with Spring Boot 2.6 wil stay broken for now? @danielfernandez - maybe you can say something about that as it seems you are the relevant guy here...
I got the same error, with spring boot 2.4.12(spring core 5.3.12) and thymeleaf 3.0.12.RELEASE, mockito-core:4.2.0. Also, do you have some tutorial how to use the testing library? I follow the README to set up the most simple test case and only got this exception. Try to google but it seems there is not much resources out there?
Appreciated!