thymeleaf-testing icon indicating copy to clipboard operation
thymeleaf-testing copied to clipboard

Support for Mockito 4

Open nspiess opened this issue 3 years ago • 4 comments

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

nspiess avatar Dec 08 '21 11:12 nspiess

will this actually be solved with https://github.com/thymeleaf/thymeleaf-testing/pull/22? I see that mockito 4 is there as dependency..

nspiess avatar Dec 08 '21 11:12 nspiess

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.

fabianfrz avatar Dec 08 '21 22:12 fabianfrz

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...

OmarHawk avatar Feb 01 '22 14:02 OmarHawk

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!

LiuGavin avatar Mar 04 '22 19:03 LiuGavin