image

Acesse bootcamps ilimitados e +650 cursos

50
%OFF
Article image

RF

Rafael Frois28/01/2025 21:18
Compartilhe

Internal Error occurred. JUnit Mockito

    Ao inicialiar o teste, após a importação do Mockito apresentou o erro: Internal Error occurred. -- Abaixo a menssagem de erro completa --
    
    Foi identificado que a divergência entre as versões do JUnit e Mockito 
    JUnit estava na versão 5.8.2 e o mockito 5.15.2(versão atual)
    ao atualizar a versão do junit para 5.11.4(versão atual), foi corrigido o erro.
    
    
    
    Importação no POM.XML
    
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <version>5.11.4</version>
      <scope>test</scope>
    </dependency>
    
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-junit-jupiter</artifactId>
      <version>5.15.2</version>
      <scope>test</scope>
    </dependency>
    
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>5.15.2</version>
      <scope>test</scope>
    </dependency>
    
    
    
    
    org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests
      at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:160)
      at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverSafely(EngineDiscoveryOrchestrator.java:132)
      at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:107)
      at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discover(EngineDiscoveryOrchestrator.java:78)
      at org.junit.platform.launcher.core.DefaultLauncher.discover(DefaultLauncher.java:99)
      at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:85)
      at org.junit.platform.launcher.core.DelegatingLauncher.execute(DelegatingLauncher.java:47)
      at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:63)
      at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57)
      at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
      at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
      at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
      at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
      at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)
    Caused by: org.junit.platform.commons.JUnitException: ClassSelector [className = 'com.dioBootcamp.mockito.mocktoTeste.EnviarMenssagemTeste', classLoader = null] resolution failed
      at org.junit.platform.launcher.listeners.discovery.AbortOnFailureLauncherDiscoveryListener.selectorProcessed(AbortOnFailureLauncherDiscoveryListener.java:39)
      at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolveCompletely(EngineDiscoveryRequestResolution.java:103)
      at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.run(EngineDiscoveryRequestResolution.java:83)
      at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolver.resolve(EngineDiscoveryRequestResolver.java:113)
      at org.junit.jupiter.engine.discovery.DiscoverySelectorResolver.resolveSelectors(DiscoverySelectorResolver.java:46)
      at org.junit.jupiter.engine.JupiterTestEngine.discover(JupiterTestEngine.java:69)
      at org.junit.platform.launcher.core.EngineDiscoveryOrchestrator.discoverEngineRoot(EngineDiscoveryOrchestrator.java:152)
      ... 13 more
    Caused by: java.lang.NoSuchMethodError: 'boolean org.junit.platform.commons.util.ReflectionUtils.returnsVoid(java.lang.reflect.Method)'
      at org.junit.jupiter.engine.discovery.predicates.IsTestableMethod.test(IsTestableMethod.java:48)
      at org.junit.jupiter.engine.discovery.predicates.IsTestMethod.test(IsTestMethod.java:23)
      at org.junit.jupiter.engine.discovery.predicates.IsTestableMethod.test(IsTestableMethod.java:26)
      at java.base/java.util.function.Predicate.lambda$or$2(Predicate.java:101)
      at java.base/java.util.function.Predicate.lambda$or$2(Predicate.java:101)
      at org.junit.platform.commons.util.ReflectionUtils.findMethod(ReflectionUtils.java:1560)
      at org.junit.platform.commons.util.ReflectionUtils.isMethodPresent(ReflectionUtils.java:1409)
      at org.junit.jupiter.engine.discovery.predicates.IsTestClassWithTests.hasTestOrTestFactoryOrTestTemplateMethods(IsTestClassWithTests.java:50)
      at org.junit.jupiter.engine.discovery.predicates.IsTestClassWithTests.test(IsTestClassWithTests.java:46)
      at org.junit.jupiter.engine.discovery.ClassSelectorResolver.resolve(ClassSelectorResolver.java:67)
      at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.lambda$resolve$2(EngineDiscoveryRequestResolution.java:135)
      at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
      at java.base/java.util.ArrayList$ArrayListSpliterator.tryAdvance(ArrayList.java:1602)
      at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
      at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527)
      at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
      at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
      at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
      at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
      at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647)
      at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:189)
      at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolve(EngineDiscoveryRequestResolution.java:126)
      at org.junit.platform.engine.support.discovery.EngineDiscoveryRequestResolution.resolveCompletely(EngineDiscoveryRequestResolution.java:92)
      ... 18 more
    
    
    Process finished with exit code -2
    
    
    
    
    
    Compartilhe
    Comentários (0)