Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Junit5 + Mockito testcases are not working in Eclipse(Junit5 + Mockito testcases are not working in Eclipse)
Junit5 + Mockito testcases are not working in Eclipse [message #1867200] Wed, 19 June 2024 13:27 Go to next message
Ankit Gareta is currently offline Ankit GaretaFriend
Messages: 5
Registered: June 2024
Junior Member
I am trying to run Junit5 testcases with Mockito. And I have added mockito-junit-jupiter:5.7.0 maven dependency in the project

Build is successful with `maven clean install` with running same junit testcases but When I try to run the specific test case from Eclipse, it is giving me below error.

org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: interface com.welldyne.wellserv.app.logic.services.CheckoutAppLogicService.


If you're not sure why you're getting this error, please open an issue on GitHub.



Java               : 11
JVM vendor name    : Oracle Corporation
JVM vendor version : 11.0.22+9-LTS-219
JVM name           : Java HotSpot(TM) 64-Bit Server VM
JVM version        : 11.0.22+9-LTS-219
JVM info           : mixed mode
OS name            : Windows Server 2016
OS version         : 10.0



You are seeing this disclaimer because Mockito is configured to create inlined mocks.
You can learn about inline mocks and their limitations under item #39 of the Mockito class javadoc.


Underlying exception : java.lang.IllegalArgumentException: Could not create type
    at org.mockito.junit.jupiter.MockitoExtension.beforeEach(MockitoExtension.java:159)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
    Suppressed: java.lang.NullPointerException
        at org.mockito.junit.jupiter.MockitoExtension.afterEach(MockitoExtension.java:190)
        ... 2 more
Caused by: java.lang.IllegalArgumentException: Could not create type
    at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:154)
    at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:365)
    at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:174)
    at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:376)
    at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:75)
    at org.mockito.internal.creation.bytebuddy.InlineBytecodeGenerator.mockClass(InlineBytecodeGenerator.java:221)
    at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.lambda$mockClass$0(TypeCachingBytecodeGenerator.java:78)
    at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:152)
    at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:365)
    at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:174)
    at net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:376)
    at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.mockClass(TypeCachingBytecodeGenerator.java:75)
    at org.mockito.internal.creation.bytebuddy.InlineDelegateByteBuddyMockMaker.createMockType(InlineDelegateByteBuddyMockMaker.java:412)
    at org.mockito.internal.creation.bytebuddy.InlineDelegateByteBuddyMockMaker.doCreateMock(InlineDelegateByteBuddyMockMaker.java:371)
    at org.mockito.internal.creation.bytebuddy.InlineDelegateByteBuddyMockMaker.createMock(InlineDelegateByteBuddyMockMaker.java:350)
    at org.mockito.internal.creation.bytebuddy.InlineByteBuddyMockMaker.createMock(InlineByteBuddyMockMaker.java:56)
    at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:99)
    at org.mockito.internal.MockitoCore.mock(MockitoCore.java:88)
    at org.mockito.Mockito.mock(Mockito.java:2101)
    at org.mockito.internal.configuration.MockAnnotationProcessor.processAnnotationForMock(MockAnnotationProcessor.java:79)
    at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:28)
    at org.mockito.internal.configuration.MockAnnotationProcessor.process(MockAnnotationProcessor.java:25)
    at org.mockito.internal.configuration.IndependentAnnotationEngine.createMockFor(IndependentAnnotationEngine.java:44)
    at org.mockito.internal.configuration.IndependentAnnotationEngine.process(IndependentAnnotationEngine.java:72)
    at org.mockito.internal.configuration.InjectingAnnotationEngine.processIndependentAnnotations(InjectingAnnotationEngine.java:62)
    at org.mockito.internal.configuration.InjectingAnnotationEngine.process(InjectingAnnotationEngine.java:47)
    at org.mockito.MockitoAnnotations.openMocks(MockitoAnnotations.java:81)
    at org.mockito.internal.framework.DefaultMockitoSession.<init>(DefaultMockitoSession.java:43)
    at org.mockito.internal.session.DefaultMockitoSessionBuilder.startMocking(DefaultMockitoSessionBuilder.java:83)
    ... 3 more
Caused by: java.lang.NoSuchMethodError: net.bytebuddy.dynamic.loading.MultipleParentClassLoader$Builder.appendMostSpecific([Ljava/lang/Class;)Lnet/bytebuddy/dynamic/loading/MultipleParentClassLoader$Builder;
    at org.mockito.internal.creation.bytebuddy.SubclassBytecodeGenerator.mockClass(SubclassBytecodeGenerator.java:129)
    at org.mockito.internal.creation.bytebuddy.TypeCachingBytecodeGenerator.lambda$mockClass$0(TypeCachingBytecodeGenerator.java:78)
    at net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:152)
    ... 31 more
has context menu


Junit test class is as follow

@ExtendWith(MockitoExtension.class)
class CheckoutControllerTest {
 
    @InjectMocks
    private CheckoutController checkoutController;
 
    @Mock
    private CheckoutService service;

 
    @Test
    void test_happy_scenario() {
        String uniqueMemberId = "memberId123";
    
        Order order = new Order();
        Mockito.when(service.getCurrentOrder(uniqueMemberId)).thenReturn(order);
 
        ...
 
    }
 



Please find attached pom.xml file.

<?xml ....>
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.poroject.test</groupId>
    <artifactId>test-app</artifactId>
    <packaging>pom</packaging>
    <name>test-app</name>
    <version>1.0.0</version>
    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <maven.compiler.release>11</maven.compiler.release>
        <spring.boot.version>2.1.6.RELEASE</spring.boot.version>
        <spring.boot.mobile.version>1.5.22.RELEASE</spring.boot.mobile.version>
        <junit.version>4.13</junit.version>
        <aws.sdk.version>1.11.762</aws.sdk.version>
        <elasticsearch.version>7.6.2</elasticsearch.version>
        <spring.swagger.version>2.9.2</spring.swagger.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    
    </properties>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>3.2.3</version>
                </plugin>
                <plugin>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-maven-plugin</artifactId>
                    <version>${spring.boot.version}</version>
                </plugin>
                <plugin>
                    <groupId>org.jvnet.jaxb2.maven2</groupId>
                    <artifactId>maven-jaxb2-plugin</artifactId>
                    <version>0.14.0</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxb2-maven-plugin</artifactId>
                <version>2.5.0</version>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M4</version>
            </plugin>
            <plugin>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.1.0</version>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.1.0</version>
            </plugin>
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.0</version>
            </plugin>
            <plugin>
                <artifactId>maven-install-plugin</artifactId>
                <version>3.0.0-M1</version>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.target}</target>
                    <release>${maven.compiler.release}</release>
                    <forceJavacCompilerUse>true</forceJavacCompilerUse>
                    <showWarnings>true</showWarnings>
                    <compilerArgs>
                        <arg>-Xlint</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
        </plugins>
    </build>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-log4j2</artifactId>
                <version>${spring.boot.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring.boot.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-aop</artifactId>
                <version>${spring.boot.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-logging</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-freemarker</artifactId>
                <version>${spring.boot.version}</version>
            </dependency>
            <dependency>
                <groupId>commons-lang</groupId>
                <artifactId>commons-lang</artifactId>
                <version>2.6</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>3.11</version>
            </dependency>
            <dependency>
                <groupId>javax.xml.bind</groupId>
                <artifactId>jaxb-api</artifactId>
                <version>2.4.0-b180830.0359</version>
            </dependency>
            <dependency>
                <groupId>javax.activation</groupId>
                <artifactId>activation</artifactId>
                <version>1.1.1</version>
            </dependency>
            <dependency>
                <groupId>org.glassfish.jaxb</groupId>
                <artifactId>jaxb-runtime</artifactId>
                <version>2.4.0-b180830.0438</version>
            </dependency>
            <dependency>
                <groupId>com.amazonaws</groupId>
                <artifactId>aws-java-sdk-elasticsearch</artifactId>
                <version>${aws.sdk.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-databind</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-annotations</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-core</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>io.searchbox</groupId>
                <artifactId>jest</artifactId>
                <version>6.3.1</version>
            </dependency>
            <dependency>
                <groupId>org.elasticsearch</groupId>
                <artifactId>elasticsearch</artifactId>
                <version>${elasticsearch.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-databind</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-annotations</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-core</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.apache.logging.log4j</groupId>
                        <artifactId>log4j-api</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>vc.inreach.aws</groupId>
                <artifactId>aws-signing-request-interceptor</artifactId>
                <version>0.0.22</version>
            </dependency>
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpclient</artifactId>
                <version>4.5.12</version>
            </dependency>
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpcore</artifactId>
                <version>4.4.13</version>
            </dependency>
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpcore-nio</artifactId>
                <version>4.4.13</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web-services</artifactId>
                <version>${spring.boot.version}</version>
            </dependency>
            <dependency>
                <groupId>com.sun.xml.messaging.saaj</groupId>
                <artifactId>saaj-impl</artifactId>
                <version>1.5.0</version>
            </dependency>
            <dependency>
                <groupId>com.amazonaws</groupId>
                <artifactId>aws-java-sdk-cognitoidp</artifactId>
                <version>${aws.sdk.version}</version>
            </dependency>
            <dependency>
                <groupId>com.amazonaws</groupId>
                <artifactId>aws-java-sdk-sts</artifactId>
                <version>${aws.sdk.version}</version>
            </dependency>
            <dependency>
                <groupId>com.amazonaws</groupId>
                <artifactId>aws-java-sdk-iam</artifactId>
                <version>${aws.sdk.version}</version>
            </dependency>
            <dependency>
                <groupId>redis.clients</groupId>
                <artifactId>jedis</artifactId>
                <version>3.2.0</version>
            </dependency>
            <dependency>
                <groupId>javax.mail</groupId>
                <artifactId>mail</artifactId>
                <version>1.5.0-b01</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-data-redis</artifactId>
                <version>${spring.boot.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-logging</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>com.amazonaws</groupId>
                <artifactId>aws-java-sdk</artifactId>
                <version>${aws.sdk.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-databind</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-annotations</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>com.fasterxml.jackson.core</groupId>
                        <artifactId>jackson-core</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>4.0.1</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>${junit.version}</version>
                <scope>test</scope>
            </dependency>
            <dependency>
                <groupId>javax.servlet.jsp</groupId>
                <artifactId>javax.servlet.jsp-api</artifactId>
                <version>2.3.3</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>jstl</artifactId>
                <version>1.2</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-web</artifactId>
                <version>${spring.boot.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-logging</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-tomcat</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-security</artifactId>
                <version>${spring.boot.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-logging</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-mobile</artifactId>
                <version>${spring.boot.mobile.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-logging</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger-ui</artifactId>
                <version>${spring.swagger.version}</version>
                <scope>compile</scope>
                <exclusions>
                    <exclusion>
                        <groupId>net.bytebuddy</groupId>
                        <artifactId>byte-buddy</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>io.springfox</groupId>
                <artifactId>springfox-swagger2</artifactId>
                <version>${spring.swagger.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>net.bytebuddy</groupId>
                        <artifactId>byte-buddy</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>commons-io</groupId>
                <artifactId>commons-io</artifactId>
                <version>2.6</version>
            </dependency>
            <dependency>
                <groupId>commons-fileupload</groupId>
                <artifactId>commons-fileupload</artifactId>
                <version>1.4</version>
            </dependency>
            <dependency>
                <groupId>com.amazonaws</groupId>
                <artifactId>aws-java-sdk-cognitoidentity</artifactId>
                <version>${aws.sdk.version}</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
                <version>${spring.boot.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-logging</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.springframework.security.extensions</groupId>
                <artifactId>spring-security-saml2-core</artifactId>
                <version>1.0.10.RELEASE</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.springframework.security</groupId>
                        <artifactId>spring-security-core</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.springframework.security</groupId>
                        <artifactId>spring-security-web</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>org.springframework.security</groupId>
                        <artifactId>spring-security-config</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.opensaml</groupId>
                <artifactId>opensaml</artifactId>
                <version>2.6.4</version>
            </dependency>
            <dependency>
                <groupId>org.bouncycastle</groupId>
                <artifactId>bcprov-ext-jdk15on</artifactId>
                <version>1.65</version>
            </dependency>
            <dependency>
                <groupId>de.brendamour</groupId>
                <artifactId>jpasskit</artifactId>
                <version>0.1.1</version>
            </dependency>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-web</artifactId>
                <version>2.12.1</version>
            </dependency>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-data-jpa</artifactId>
                <version>${spring.boot.version}</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.springframework.boot</groupId>
                        <artifactId>spring-boot-starter-logging</artifactId>
                    </exclusion>
                    <exclusion>
                        <groupId>net.bytebuddy</groupId>
                        <artifactId>byte-buddy</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.postgresql</groupId>
                <artifactId>postgresql</artifactId>
                <version>9.3-1100-jdbc41</version>
            </dependency>
            <dependency>
                <groupId>com.google.guava</groupId>
                <artifactId>guava</artifactId>
                <version>29.0-jre</version>
            </dependency>
        
            <!--<dependency>
                <groupId>org.junit.jupiter</groupId>
                <artifactId>junit-jupiter-engine</artifactId>
                <version>5.10.2</version>
                <scope>test</scope>
            </dependency> -->
            <dependency>
                <groupId>org.mockito</groupId>
                <artifactId>mockito-junit-jupiter</artifactId>
                <version>5.7.0</version>
                <!--<scope>test</scope> -->
            </dependency>
        </dependencies>
    </dependencyManagement>
    
</project>


I tried to check Eclipse configurations and it is pointing to the same java versions, and there is no duplicate library as well for net.bytebuddy.

I have been using 2023-03 (4.31.0) eclipse version.

Could you please help me to resolve the issue ?
Re: Junit5 + Mockito testcases are not working in Eclipse [message #1867206 is a reply to message #1867200] Wed, 19 June 2024 17:27 Go to previous messageGo to next message
Erik BrangsFriend
Messages: 55
Registered: February 2010
Member
The stack trace shows a NoSuchMethodError . This probably means that the dependency resolution picks the wrong version of ByteBuddy.

Your POM has lots of exclusions. The problem with exclusions is that you can cause errors if you exclude the wrong libraries at the wrong place. If you just need to pick the correct version of a library, I would advise you to use the dependencyManagement mechanism instead.

You also use both JUnit 4 and JUnit Jupiter (= Junit 5) in your POM. This could cause problems. I would advise you to stick to JUnit Jupiter. Your example uses @ExtendWith which is a Junit 5 annotation. You should use JUnit Jupiter's support for Junit 4 tests. If that's not possible, rewrite the affected tests to use JUnit Jupiter.

That said, I don't actually know why the behaviour betweeen command line and Eclipse differs, so take my advice with a grain of salt.
Re: Junit5 + Mockito testcases are not working in Eclipse [message #1867209 is a reply to message #1867206] Wed, 19 June 2024 17:35 Go to previous messageGo to next message
Ankit Gareta is currently offline Ankit GaretaFriend
Messages: 5
Registered: June 2024
Junior Member
Thank you for the reply.

We do not have any Junit4 testcases in our project. Somehow the dependency is there from the starting. I tried with commented out junit4 dependency. But same result.

I checked for ByteBuddy in pom dependency tree, and there is only one reference and it is coming with mockito-jupiter depdency.
Re: Junit5 + Mockito testcases are not working in Eclipse [message #1867212 is a reply to message #1867206] Wed, 19 June 2024 17:35 Go to previous messageGo to next message
Ankit Gareta is currently offline Ankit GaretaFriend
Messages: 5
Registered: June 2024
Junior Member
Thank you for the reply.

We do not have any Junit4 testcases in our project. Somehow the dependency is there from the starting. I tried with commented out junit4 dependency. But same result.

I checked for ByteBuddy in pom dependency tree, and there is only one reference and it is coming with mockito-jupiter depdency.
Re: Junit5 + Mockito testcases are not working in Eclipse [message #1867215 is a reply to message #1867212] Wed, 19 June 2024 18:34 Go to previous messageGo to next message
Erik BrangsFriend
Messages: 55
Registered: February 2010
Member
I'm out of ideas if you're absolutely sure that the right version of ByteBuddy is being used in the module that contains your test case. The code that you've shown is incomplete, so it's not possible to do debugging without more information.

I suggested dependencyManagement instead of exclusions because that allows you to pick the version of byteBuddy. You can then use the "Dependency Hierarchy" tab in the POM editor and see which version is required by mockito-junit-jupiter and which version is required by your other dependencies. You can then also experiment and see if anything changes when you pick another version from the possible versions.
Re: Junit5 + Mockito testcases are not working in Eclipse [message #1867236 is a reply to message #1867206] Thu, 20 June 2024 05:35 Go to previous messageGo to next message
Ankit Gareta is currently offline Ankit GaretaFriend
Messages: 5
Registered: June 2024
Junior Member
Thank you for the reply.

We do not have any Junit4 testcases in our project. Somehow the dependency is there from the starting. I tried with commented out junit4 dependency. But same result.

I checked for ByteBuddy in pom dependency tree, and there is only one reference and it is coming with mockito-jupiter depdency.
Re: Junit5 + Mockito testcases are not working in Eclipse [message #1867239 is a reply to message #1867215] Thu, 20 June 2024 05:40 Go to previous messageGo to next message
Ankit Gareta is currently offline Ankit GaretaFriend
Messages: 5
Registered: June 2024
Junior Member
Hello,

bytebuddy depdency is coming from mockito-junit-jupiter depdency itself.
We haven't explicitly added that.

Image : https://i.sstatic.net/D1mtTJ4E.png
Re: Junit5 + Mockito testcases are not working in Eclipse [message #1867287 is a reply to message #1867239] Thu, 20 June 2024 16:33 Go to previous messageGo to next message
Erik BrangsFriend
Messages: 55
Registered: February 2010
Member
As I wrote before, I don't have any good ideas left. Some things to check:
- mockito-junit-jupiter is on the compile classpath because you've commented out the test scope. Does the problem also occur when it's only on the test classpath?
- does the problem still appear with the newest version of mockito-junit-jupiter?

I suppose you could also try to produce a minimal working example, as described on https://stackoverflow.com/help/minimal-reproducible-example . This may help others spot the problem.
Re: Junit5 + Mockito testcases are not working in Eclipse [message #1868241 is a reply to message #1867287] Tue, 16 July 2024 07:24 Go to previous message
Dameon Abbott is currently offline Dameon AbbottFriend
Messages: 1
Registered: July 2024
Junior Member
I contacted support and they said to update mockito-junit-jupiter to the latest version to see if the problem is resolved. I checked the Maven repository for the latest version but the problem persists. Is there any other way to solve this problem?
basket random

[Updated on: Wed, 17 July 2024 07:30]

Report message to a moderator

Previous Topic:Missing code implementation in the compiler
Next Topic:ABAP Development Tools installation failed
Goto Forum:
  


Current Time: Sat Jan 18 18:47:10 GMT 2025

Powered by FUDForum. Page generated in 0.03428 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top