Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Execute one test in a Maven project
Execute one test in a Maven project [message #1860049] Fri, 14 July 2023 02:49 Go to next message
Earl Harris is currently offline Earl HarrisFriend
Messages: 8
Registered: August 2013
Junior Member
I have a maven project in Eclipse that contains junit 5 test classes.
If I right-click on a specific test class and do a Run As -> Maven test, ALL the test classes are activated. I only wanted to start the particular test class I selected.
What do I have to do to get the desired effect? Executing one test class is a common thing to do.
Here is my POM.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.earl</groupId>
<artifactId>SeleniumTests2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<java.version>17</java.version>
<slf4j.version>2.0.7</slf4j.version>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>4.10.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-http-jdk-client</artifactId>
<version>4.10.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>${slf4j.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-api -->
<!-- <dependency>-->
<!-- <groupId>org.junit.jupiter</groupId>-->
<!-- <artifactId>junit-jupiter-api</artifactId>-->
<!-- <version>5.9.3</version>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.9.3</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-params -->
<!-- <dependency>-->
<!-- <groupId>org.junit.jupiter</groupId>-->
<!-- <artifactId>junit-jupiter-params</artifactId>-->
<!-- <version>5.9.3</version>-->
<!-- <scope>test</scope>-->
<!-- </dependency>-->
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-migrationsupport -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-migrationsupport</artifactId>
<version>5.9.3</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
Re: Execute one test in a Maven project [message #1860051 is a reply to message #1860049] Fri, 14 July 2023 05:39 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33264
Registered: July 2009
Senior Member
The launch configuration's first tab has configuration choices where you can "Run a single test" and can specify a class and its method.

Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Execute one test in a Maven project [message #1860097 is a reply to message #1860049] Mon, 17 July 2023 18:05 Go to previous message
David M. Karr is currently offline David M. KarrFriend
Messages: 810
Registered: July 2009
Senior Member
If you just want to run a single test inside Eclipse, you can simply select "Unit Test" from the "Run As" menu.
Previous Topic:TestNG
Next Topic:RepositoryManipulationPage
Goto Forum:
  


Current Time: Mon Jan 13 20:32:40 GMT 2025

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

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

Back to the top