I have a project in which I have used Juint5 for creating tests and test suites. I want to run the test suite via the pom file. Below is the pom file and test suit which I have created. when I run the mvn clean
it does not execute any tests but when I manually run the test suite run as JUnit test
all the test cases are executed
can someone please help me here?
Suite file
@RunWith(JUnitPlatform.class)
@SelectClasses( {TestA.class,TestB.class} )
@IncludeTags("unitTest")
public class Testsuite
{
}
classes
public class TestA
{
@Test
@Tag("unitTest")
static void myMethod1()
{
System.out.println("Hello World!");
}
}
public class TestB
{
@Test
@Tag("unitTest")
static void myMethod2()
{
System.out.println("Hello World!");
}
}
pom file entry
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<includes>
<include>**/Testsuite*</include>
</includes>
</configuration>
</plugin>
full pom file
<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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.junit.karte.emo</groupId>
<artifactId>cg-automation</artifactId>
<version>0.0.1-SNAPSHOT</version>
<!-- <packaging>jar</packaging> -->
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<cucumber.reporting.version>5.3.1</cucumber.reporting.version>
<karate.version>0.9.6</karate.version>
<junit.runner.version>1.0.18</junit.runner.version>
<commons.lang3.version>3.11</commons.lang3.version>
<jsch.version>0.1.55</jsch.version>
<junit.jupiter.engine.version>5.6.2</junit.jupiter.engine.version>
<junit-jupiter-api.version>5.8.0-M1</junit-jupiter-api.version>
<junit.platform.runner>1.6.2</junit.platform.runner>
<cg_password>n</cg_password>
<host_ip>10.204.100.136</host_ip>
<host_usrname>root</host_usrname>
<host_password>n</host_password>
<build_name>change_guardian-6.2</build_name>
<custom_path>/usr</custom_path>
<cg_version>8.5.0.0.13</cg_version>
<web_port>8443</web_port>
<win_host>vlab007206</win_host>
<win_ip>10.204.108.65</win_ip>
<win_user>administrator@cgdom100.lab</win_user>
<win_password>Control4321</win_password>
<asset_type>win</asset_type>
<unix_host>vlab007201</unix_host>
<unix_ip>10.204.100.136</unix_ip>
<unix_user>root</unix_user>
<unix_password>n</unix_password>
<base_build>change_guardian-6.1</base_build>
<basecg_version>8.3</basecg_version>
<maven.compiler.version>3.8.1</maven.compiler.version>
<maven.surefire.version>2.22.2</maven.surefire.version>
<maven.site.version>3.7.1</maven.site.version>
<maven.surefire.report.version>3.0.0.M5</maven.surefire.report.version>
<maven.project.info.reports.version>3.0.0</maven.project.info.reports.version>
<runSuite>StanderdPathInstall.java</runSuite>
<groups>StanderdPathInstall</groups>
</properties>
<repositories>
<repository>
<id>sm.releases</id>
<name>NetIQ Security Management site - RELEASES</name>
<url>https://btpartifactory.swinfra.net:443/artifactory/security-sentinel-mvn-releases/</url>
<releases>
<enabled>true</enabled>
<updatePolicy>${repository-updatePolicy}</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>${repository-updatePolicy}</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</snapshots>
</repository>
<repository>
<id>sm.snapshots</id>
<name>NetIQ Security Management site - SNAPSHOTS</name>
<url>https://btpartifactory.swinfra.net:443/artifactory/security-sentinel-mvn-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>${repository-updatePolicy}</updatePolicy>
</snapshots>
</repository>
<repository>
<id>central</id>
<name>Central Repository</name>
<url>https://repo.maven.apache.org/maven2/</url>
<layout>default</layout>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>apache.central</id>
<name>Apache Maven Central Repository</name>
<url>https://repository.apache.org/content/repositories/releases/</url>
</repository>
<repository>
<id>maven2-repository.dev.java.net</id>
<name>Java.net Repository for Maven</name>
<url>http://download.java.net/maven/2/</url>
<layout>default</layout>
</repository>
<repository>
<id>maven2-maven-org</id>
<url>https://repo1.maven.org/maven2/</url>
</repository>
</repositories>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter-engine -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.8.0-M1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-apache</artifactId>
<version>${karate.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.intuit.karate</groupId>
<artifactId>karate-junit5</artifactId>
<version>${karate.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.pantsbuild</groupId>
<artifactId>junit-runner</artifactId>
<version>${junit.runner.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons.lang3.version}</version>
</dependency>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>${jsch.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.jupiter.engine.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>${junit-jupiter-api.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.1.0</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-runner</artifactId>
<version>${junit.platform.runner}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testResources>
<testResource>
<directory>src/test/java</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.compiler.version}</version>
<configuration>
<encoding>UTF-8</encoding>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgument>-Werror</compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
<configuration>
<includes>
<include>StanderdPathInstall.java</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>${maven.site.version}</version>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>${maven.surefire.report.version}</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>${maven.project.info.reports.version}</version>
</plugin>
</plugins>
</reporting>
</project>
My solution is
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<groups>integration</groups>
</configuration>
</plugin>
mvn test -Dgroups="integration"