Not able to run JUnit on IDE

Hi, I am using Eclipse IDE for importing java project. I am able to run the project on command prompt as “mvn spring-boot:run”. but when I try to run the JUnit on Eclipse IDE, I am getting an error “No tests found with test runner JUNIT5”. I can see the JUNIT jar present in my dependencies, also all the annotations are present. Could you please help me resolve this issue.

Hi @Prabhas_Sagdeo,

You can refer to the following links to debug the issue:

If you still get the same issue, I would recommend you to share the Java and eclipse version.

Please feel free to reach out if you have any questions.

Thanks,
Sonali

1 Like

Hi @Sonali_Mamgain ,

My eclipse version id is as below.
Eclipse IDE for Enterprise Java Developers.

Version: 2019-12 (4.14.0)

I am using JDK 13.0.2

That looks good to me. Are you able to run the test commands from command line?
We have shared that in our lab description. Maybe try that out if it works.

Kanika

I had the same issue and updated some dependency versions. Below pom.xml config worked for me. Use it if you still need it.

<?xml version="1.0" encoding="UTF-8"?>


4.0.0

org.springframework.boot
spring-boot-starter-parent
2.2.13.RELEASE


mongodb.university
mflix
1.0-SNAPSHOT

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <!-- <version>2.0.3.RELEASE</version> -->
    </dependency>
    
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <!-- <version>2.0.3.RELEASE</version> -->
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
        <!-- <version>2.0.4.RELEASE</version> -->
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot</artifactId>
        <!-- <version>2.0.4.RELEASE</version> -->
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <!-- <version>5.0.7.RELEASE</version> -->
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-core</artifactId>
       <!--  <version>5.0.7.RELEASE</version> -->
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-autoconfigure</artifactId>
       <!--  <version>2.0.3.RELEASE</version> -->
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-web</artifactId>
      <!--   <version>5.0.7.RELEASE</version> -->
    </dependency>
    <dependency>
        <groupId>io.jsonwebtoken</groupId>
        <artifactId>jjwt</artifactId>
        <version>0.9.1</version>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
       <!--  <version>5.1.0</version> -->
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mongodb</groupId>
        <artifactId>mongodb-driver-sync</artifactId>
        <version>3.11.0</version>
    </dependency>
    <!-- https://mvnrepository.com/artifact/org.mongodb/mongo-java-driver -->
     <!-- <dependency>
    <groupId>org.junit.jupiter</groupId>
    <artifactId>junit-jupiter-engine</artifactId>
    <version>5.4.0</version>
    <scope>test</scope>
</dependency>
 <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-params</artifactId>
        <version>5.4.0</version>
        <scope>test</scope>
    </dependency> -->
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
           <!--  <version>3.7.0</version> -->
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <showDeprecation>true</showDeprecation>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <!-- <version>2.22.0</version> -->
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
           <!--  <version>3.0.0</version> -->
        </plugin>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <!-- <version>2.0.3.RELEASE</version> -->
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>
<reporting>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-checkstyle-plugin</artifactId>
           <!--  <version>3.0.0</version> -->
            <configuration>
                <configLocation>google_checks.xml</configLocation>
            </configuration>
            <reportSets>
                <reportSet>
                    <reports>
                        <report>checkstyle</report>
                    </reports>
                </reportSet>
            </reportSets>
        </plugin>
    </plugins>
</reporting>