"java.lang.NoSuchMethodError: org.mockito.Mockito.mockitoSession()" error in 'beforeEach' method inside MockitoExtension
See original GitHub issueDependecies:
junit-jupiter-api: 5.2.0 junit-jupiter-engine: 5.2.0 mockito-core: 2.18.3 mockito-junit-jupiter: 2.18.3
Test:
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.WARN)
public class AccountTest
{
@InjectMocks
private Account account;
@Mock
private AccountConfiguration accountConfiguration;
@Test
public void shouldSetAccountInfoToRequest()
{
// test logic
}
}
Actual result:
java.lang.NoSuchMethodError: org.mockito.Mockito.mockitoSession()Lorg/mockito/session/MockitoSessionBuilder;
at org.mockito.junit.jupiter.MockitoExtension.beforeEach(MockitoExtension.java:112)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachCallbacks$0(TestMethodTestDescriptor.java:129)
at org.junit.jupiter.engine.execution.ThrowableCollector.execute(ThrowableCollector.java:40)
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:155)
Issue Analytics
- State:
- Created 5 years ago
- Reactions:3
- Comments:9
Top Results From Across the Web
pom.xml - Stack Overflow
Can someone help me please what is my mistake? The error received: java.lang.NoSuchMethodError: org.mockito.Mockito.framework()Lorg/mockito/ ...
Read more >NoSuchMethodError using 'when' on mockito 1.6
When running the test it fails on the 'when' method call with this error: java.lang.NoSuchMethodError: org.mockito.Mockito.when(Ljava/lang/
Read more >Java.Lang.Nosuchmethoderror: Org.Mockito.Mockingdetails ...
java.lang.NoSuchMethodError: org.mockito.Mockito.mockitoSession error in 'beforeEach' method inside MockitoExtension #1394. java.lang.
Read more >org.mockito.session.MockitoSessionBuilder.initMocks java ...
public void evaluate() throws Throwable { if (session == null) { session = Mockito.mockitoSession() .name(target.getClass().getSimpleName() + "." + method.
Read more >java.lang.NoSuchMethodError: org.mockito.Mockito
This was giving me the following error when I ran the test case: java.lang.NoSuchMethodError: org.mockito.Mockito.when(Ljava/lang/Object ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’m having the same issue
Ah, I removed:
and it started working (I already had
mockito-all
)I also get this when doing something has basic as above. However, when I run the tests from the command line via Maven, there is no problem. It seems that I get this only when running the tests from within IntelliJ