How to configure TestNG test method group in pom.xml - maven

I'm able to run all my tests but i don't know how to configure group in pom.xml and run the test group using maven.
I'm using TestNG frame work but nothing added like testing.xml in pom.xml.
can anyone please help me to make group in pom.xml using testng.. Below is my pom.xml
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.automation.tests</groupId>
<artifactId>autotest</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>autotest</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<classifier>jdk15</classifier>
<version>5.11</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>LATEST</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<!--<executions> <execution> <phase>pre-integration-test</phase> <goals>
<goal>start-server</goal> </goals> <configuration> <background>true</background>
</configuration> </execution> <execution> <id>stop-selenium</id> <phase>post-integration-test</phase>
<goals> <goal>stop-server</goal> </goals> </execution> </executions> -->
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- Skip the normal tests, we'll run them in the integration-test phase -->
<skip>true</skip>
</configuration>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

If you have the groups defined in your cases, and you want to specify the group in your pom, then you can do the following in your pom. By default, the test phase uses surefire plugin, but you can define the following explicitly to have your groups
<plugins>
[...]
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<configuration>
<groups>functest,perftest</groups>
</configuration>
</plugin>
[...]

What I typically do is defining a test cases which I want to run under src/test/resources/testng folder, so let's say you will have
src/test/resources/testng/testSuite1.xml
src/test/resources/testng/testSuite2.xml
Now, you can run these suits with simple command like
mvn verify -Dtestng.suite.xml=src/test/resources/testng/testSuite1.xml
Sample TestNG file
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="seleniumTest">
<test name="All Components">
<groups>
<run>
<include name="Some group" />
</run>
</groups>
<packages>
<package name="org.package" />
<package name="org.package2" />
</packages>
</test>

Related

Sonarcloud covergare is not calculated

I am trying to configure sonarqube coverage for my project.
My pom file is as below, when I run mvn verify it creates jacoco.exec file in target directory and when I configure local sonar it shows the coverage, but in sonar cloud I my coverage is not calculated. What is the missing part in the following file
My other questions;
Do I need to configure jacoco.exec file location in sonar cloud.
What is the point of configuring jacoco in profile rather than plugin
Thanks.
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.4</version>
<relativePath/>
</parent>
<groupId>group</groupId>
<artifactId>backend</artifactId>
<version>1.0.0</version>
<name>project</name>
<description>Spring Boot Backend</description>
<properties>
<java.version>17</java.version>
<sonar.java.source>17</sonar.java.source>
<checkstyle-maven-plugin.version>3.2.0</checkstyle-maven-plugin.version>
<checkstyle-version>10.3.4</checkstyle-version>
<maven-site.version>3.7.1</maven-site.version>
<jacoco.version>0.8.8</jacoco.version>
<jacoco.path>${project.basedir}/../target/jacoco.exec</jacoco.path>
<sonar.coverage.jacoco.xmlReportPaths>${basedir}/target/jacoco_report/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
</properties>
<dependencies>
<!-- Check style -->
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle-maven-plugin.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle-maven-plugin.version}</version>
<configuration>
<consoleOutput>true</consoleOutput>
<failsOnError>true</failsOnError>
<configLocation>google_checks.xml</configLocation>
</configuration>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>${checkstyle-version}</version>
</dependency>
</dependencies>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>${maven-site.version}</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<!--suppress UnresolvedMavenProperty -->
<argLine>${surefireArgLine}</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco.version}</version>
<executions>
<execution>
<id>pre-unit-test</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<outputDirectory>${jacoco.path}</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle-maven-plugin.version}</version>
<reportSets>
<reportSet>
<reports>
<report>checkstyle</report>
</reports>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
</project>
The "exec" format is deprecated. You should have the following properties:
<sonar.coverage.jacoco.xmlReportPaths>${basedir}/target/jacoco_report/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
<jacoco.path>${basedir}/target/jacoco_report</jacoco.path>
I know that some documentation states that the jacoco.path value ends with "jacoco.exec", but I believe it is supposed to be the directory, and where the "xml" file is stored, not the "exec" file.
We've been using these settings for years.
Note that you should also verify that the build is producing these files. One good way to verify it is to look for the "index.html file in the "jacoco_report" directory and open that. It will show your coverage results, from jacoco's point of view (note that SonarQube's coverage computation algorithm is slightly different from Jacoco's).

Inconsistent behaviour between maven-surefire and tycho-surefire, with jacoco not generating reports

I'm working on creating a pom for a project and adding test cases to it. The project is an eclipse plugin.
Compiling the project with tycho works just fine, the only problem is during testing:
If I run both maven-surefire-plugin tests and tycho-surefire-plugin-tests, the former performs all the tests as expected, while the latter gives the following error:
Execution test of goal org.eclipse.tycho:tycho-surefire-plugin:1.7.0:test failed: Tycho build extension not configured for MavenProject
I would be perfectly fine to just add <skipTests>true</skipTests> to the tycho-surefire-plugin while keeping maven-surefire-plugin on; the problem is even that way, jacoco refuses to create the coverage site, with the following (non error) message:
Skipping JaCoCo execution due to missing execution data file.
I tried to look for solutions of both, but any combination of the solutions I found doesn't lead me to having a working coverage site.
Maven really makes me quite confused, especially with tycho around, so I'd apreciate any explanation on top of the actual fix.
Here is my pom:
<?xml version="1.0"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>mygroupid</groupId>
<artifactId>myartifactid</artifactId>
<name>myname</name>
<packaging>eclipse-test-plugin</packaging>
<properties>
<tycho-version>1.7.0</tycho-version>
</properties>
<parent>
<groupId>parentgroupid</groupId>
<artifactId>parent</artifactId>
<version>0.9.5</version>
</parent>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
</dependency>
<dependency>
<groupId>javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.12.1.GA</version>
</dependency>
</dependencies>
<build>
<testSourceDirectory>src/test/java/</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
</configuration>
<executions>
<execution>
<id>test</id>
<phase>test</phase>
<configuration>
<includes>
<include>**/Test_*.java</include>
</includes>
</configuration>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<skipTests>true</skipTests>
</configuration>
<executions>
<execution>
<id>test</id>
<phase>test</phase>
<configuration>
<includes>
<include>**/Test_*.java</include>
</includes>
</configuration>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
<configuration>
<output>file</output>
<append>true</append>
<includes>
<include>**/path_to_source/**/*</include>
</includes>
</configuration>
<executions>
<execution>
<id>jacoco-initialize</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>jacoco-site</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>compiletests</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
And here is my parent pom:
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>parentgroupid</groupId>
<artifactId>parent</artifactId>
<version>0.9.5</version>
<packaging>pom</packaging>
<modules>
<module>moduleid</module>
</modules>
<properties>
<tycho-version>1.7.0</tycho-version>
</properties>
<repositories>
<repository>
<id>eclipse-2020-06</id>
<layout>p2</layout>
<url>http://download.eclipse.org/releases/2020-06</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
<configuration>
<includeAllDependencies>true</includeAllDependencies>
</configuration>
</plugin>
</plugins>
</build>
</project>
Of course there won't be any test result for the JaCoCo due to you are using very old Surefire version 2.12.4. This version was not created for JUnit5.
Use the latest version 3.0.0-M5 and see the tutorial.
If you want to have tiny POM, remove the dependency junit-jupiter-engine due to you do not need to have an access to the JUnit internals in your test code. The Surefire will download it shortly before the test runtime.
Your POM has several errors. Let's start with the root cause and then other priorities from high to low.
Whole problem is that Surefire does not know about JaCoCo. You have to tel "him" this way (see jacoco.agent) which "wires" both. Pls ead the documentation in the JaCoCo project:
<properties>
<jvm.args.tests>-Xmx2048m -Xms1024m -XX:SoftRefLRUPolicyMSPerMB=50 -Djava.awt.headless=true -Djdk.net.URLClassPath.disableClassPathURLCheck=true</jvm.args.tests>
<properties>
...
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>${jvm.args.tests} ${jacoco.agent}</argLine>
</configuration>
...
The next error is with the way how you use plugins. The plugin jacoco-maven-plugin must be used only in the plugins section. The problem is that you use it also in the dependencies section. You do not want to have it on the classpath. It is job of the property jacoco.agent to put the jacoco agent on the test classpth only but there the JaCoCo plugin must start before the Surefire plugin.
The next thing i do not understand is the config of the compiler. Why you have this?
<executions>
<execution>
<id>compiletests</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
I have second question regarding the packaging. I have never seen this one. It isn't a standard packaging.
<packaging>eclipse-test-plugin</packaging>
Has the Eclipse plugin any special binary form of the archive file?

How to run multiple jmeter .jmx tests with multiple input files using jmeter.maven.plugin

I need to be able to run jmeter tests from jenkins using mvn and jmeter-maven-plugin.
Here is the file setup:
test_dev.jmx
test_dev.txt
test_dev_regression.jmx
test_dev_regression.txt
Here is the pom file used by the mvn command (below):
<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.example</groupId>
<artifactId>JmeterTest</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>JMeter Example </name>
<properties>
<input.jmx.folder>${project.basedir}/src/test/jmeter</input.jmx.folder>
<input.jmx.file>test_${Environment}.jmx</input.jmx.file>
<input.csv>${project.basedir}/src/test/jmeter/test_${Environment}.txt</input.csv>
</properties>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>com.lazerycode.jmeter</groupId>
<artifactId>jmeter-maven-plugin</artifactId>
<version>2.9.0</version>
<configuration>
<propertiesUser>
<threadgroup00.dataFile>${input.csv}</threadgroup00.dataFile>
</propertiesUser>
<testFilesIncluded>
<!-- If spcified, only particular file will be processed. -->
<jMeterTestFile>${input.jmx.file}</jMeterTestFile>
</testFilesIncluded>
<testResultsTimestamp>false</testResultsTimestamp>
<!-- This will pick up all the jmx file at below folder. -->
<testFilesDirectory>${input.jmx.folder}</testFilesDirectory>
<generateReports>true</generateReports>
<resultsFileFormat>csv</resultsFileFormat>
</configuration>
<executions>
<execution>
<id>jmeter-tests</id>
<phase>test</phase>
<goals>
<goal>jmeter</goal>
<goal>results</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
And here is the command we are using to run the tests:
mvn verify -DEnvironment=$TEST_ENVIRONMENT
As you can see, currently there are no regression tests being run. I'd like to add the regression test and it's input file into this pom so that both tests get run one after the other. The hang-up for me is the <threadgroup00.dataFile> property. What needs to be specified here to use another input file for the regression test? Or is there another way to run multiple tests with multiple inputs using this framework?
Thanks in advance!
As of version 3.0.0 you should now be able to do this, an example execution block showing the setup is:
<executions>
<execution>
<id>configuration-one</id>
<goals>
<goal>configure</goal>
</goals>
<configuration>
<resultsFileFormat>xml</resultsFileFormat>
</configuration>
</execution>
<execution>
<id>configuration-two</id>
<goals>
<goal>configure</goal>
</goals>
<configuration>
<resultsFileFormat>csv</resultsFileFormat>
</configuration>
</execution>
<execution>
<id>performance test one</id>
<goals>
<goal>jmeter</goal>
</goals>
<configuration>
<selectedConfiguration>configuration-one</selectedConfiguration>
<testFilesIncluded>
<jMeterTestFile>test1.jmx</jMeterTestFile>
</testFilesIncluded>
</configuration>
</execution>
<execution>
<id>performance test two</id>
<goals>
<goal>jmeter</goal>
</goals>
<configuration>
<selectedConfiguration>configuration-two</selectedConfiguration>
<testFilesIncluded>
<jMeterTestFile>test2.jmx</jMeterTestFile>
</testFilesIncluded>
</configuration>
</execution>
</executions>
The IT test showing this behaviour (Which the above execution example was taken from) is available at here.

Can I use Maven to generate a Jar that i can run my different Selenium TestNG tests using different testng xmls

I can use Maven to generate a directory containing my tests and dependencies and run them from the command line using "java -cp" . But I cannot get this to work in a single jar, without recreating a testng main and needing to pass testng xmls in and such. Thinking this is a simple thing being overlooked.
fundamentally I believe this may be a question of, can you create a jar that runs a main in an included package dependency? I may not be asking or stating correctly, if so, some help with that would also be appreciated.
precon, Maven 3.5.4 and Java 1.8 installed
I HAVE been able to "copy dependencies" and run the following usual TestNG command line:
java -cp %CD%\target\*; org.testng.TestNG TestTest.xml
but this is not as nice as just getting everything into one jar.
If possible, I don't want to have to recreate the TestNG main and further pass xmls etc. which I have done. I want to just use TestNG as is and package it with my tests in a single jar, and run like this:
java -jar %CD%\target\myproj-0.0.1-jar-with-dependencies.jar TestTest.xml
from My POM file pom.xml
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<skipTests>true</skipTests>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.0.0-beta3</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<!-- Source directory configuration -->
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>org.testng.TestNG</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<!-- // Following plugin executes the testng tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<!-- // Suite testng xml file to consider for test execution -->
<suiteXmlFiles>
<suiteXmlFile>testtest.xml</suiteXmlFile>
</suiteXmlFiles>
<skipTests>${skipTests}</skipTests>
</configuration>
</plugin>
</plugins>
</build>
my testNG xml TestTest.xml
<groups>
<run>
<include name="basic"/>
</run>
</groups>
<classes>
<class name="myproj.TestTest"/>
</classes>
my tests in TestTest.java
package myproj;
import org.testng.annotations.Test;
public class TestTest{
#Test(groups = { "basic" })
public void Test05BasicPASS() {
System.out.println("This is test 5, Basic Pass");
}
}
directory structure:
-testproj
pom.xml
TestTest.xml
-src
-myproj
TestTest.java
Jars get output to:
-testproj
-target
On command line I can successfully run:
mvn package -DskipTests=false
to build, run tests and generate jars with maven
After running and the jar exists, I believe I should be able to run the following and have the tests run as well:
java -jar %CD%\target\myproj-0.0.1-jar-with-dependencies.jar TestTest.xml
however I get:
Error: Could not find or load main class org.testng.TestNG
Net goal, to be able to build a project using testng and run my tests with testNG xmls on the command line.
This should work independent of any IDE.
If you want to build so callled "fat jar" - a single executable .jar containing all dependencies and invoking TestNG main class I would recommend going for Maven Shade Plugin:
Remove the following lines from your pom.xml
<scope>provided</scope>
Add the following Maven Shade plugin definition to create an executable jar:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.testng.TestNG</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
Package the jar
Once done you should be able to invoke your test as jar -jar myproj-0.0.1.jar
Full pom.xml just in case:
<?xml version="1.0" encoding="UTF-8"?>
<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.example</groupId>
<artifactId>myproj</artifactId>
<version>0.0.1</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<skipTests>true</skipTests>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.testng/testng -->
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.0.0-beta3</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
</dependencies>
<build>
<!-- Source directory configuration -->
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<mainClass>org.testng.TestNG</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<!-- // Following plugin executes the testng tests -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<!-- // Suite testng xml file to consider for test execution -->
<suiteXmlFiles>
<suiteXmlFile>testtest.xml</suiteXmlFile>
</suiteXmlFiles>
<skipTests>${skipTests}</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.testng.TestNG</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

Concordion with Maven, using different folder for integration tests

I am trying to run integration tests (written in Concordion) using Maven 3.2.5. I have done the following.
Created a maven project using quickstart archetype.
Put my source code in src/main/java, unit test in src/test/java and integration
tests in src/spec/java.
Used maven-antrun-plugin to put integration test *.class in target/integrationtest-classes
Use maven-surefire-plugin to run the unit test cases.
Use maven-failsafe-plugin to run the integration test cases.
Finally run everything using "mvn clean install"
The problem is, while the unit test cases are running, the integration test cases are not. When I run the integration test cases from Eclipse, by running them as JUnit they run alright. However, when I run them from Maven, somehow only the unit test cases run. Can someone please help.
I am attaching my pom.xml here.
<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.acme.bundler</groupId>
<artifactId>concordion</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>concordion</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Integration test. -->
<integrationSourceDirectory>src/spec/java</integrationSourceDirectory>
<integrationOutputDirectory>target/integrationtest-classes</integrationOutputDirectory>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.2</version>
</dependency>
<dependency>
<groupId>org.concordion</groupId>
<artifactId>concordion</artifactId>
<version>1.4.6</version>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<!-- Compile and run using jdk 1.7 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
<executions>
<execution>
<phase>pre-integration-test</phase>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<compilerArguments>
<d>${integrationOutputDirectory}</d>
</compilerArguments>
</configuration>
</execution>
</executions>
</plugin>
<!-- Run the main class of Java. -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.acme.bundler.concordion.App</mainClass>
<arguments>
<argument>foo</argument>
<argument>bar</argument>
</arguments>
</configuration>
</plugin>
<!-- The artefacts of integration tests need to move to a different folder
than the output of unit tests. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<id>create-directory</id>
<phase>pre-integration-test</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<echo message="Creating Directory ${integrationOutputDirectory}" />
<mkdir dir="${integrationOutputDirectory}" />
</tasks>
</configuration>
</execution>
</executions>
</plugin>
<!-- Move the .class of the .java files in integration tests. <mkdir
dir="${itest.testOutputDirectory}" /> <move todir="${itest.testOutputDirectory}">
<fileset dir="${project.build.testOutputDirectory}"> <include name="**/*.class"
/> <present targetdir="${spec.testSourceDirectory}"> <mapper type="glob"
from="*.class" to="*.java" /> </present> </fileset> </move> -->
<!-- Surefire is designed to run the unit tests. If any of the tests
break the whole build breaks. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
<configuration>
<test>**/*.java</test>
</configuration>
</plugin>
<!-- Failsafe is designed to run integration tests. -->
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.8</version>
<configuration>
<testClassesDirectory>${integrationOutputDirectory}</testClassesDirectory>
<reportsDirectory>${integrationOutputDirectory}/failsafe-reports</reportsDirectory>
<test>**/*.java</test>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<!-- Copy integration tests. -->
<execution>
<id>add-test-sources</id>
<phase>pre-integration-test</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${integrationSourceDirectory}</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-resources</id>
<phase>pre-integration-test</phase>
<goals>
<goal>add-test-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${integrationSourceDirectory}</directory>
<targetPath>${integrationOutputDirectory}</targetPath>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>add-empty-directory</id>
<phase>pre-integration-test</phase>
<goals>
<goal>add-test-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${integrationSourceDirectory}</directory>
<targetPath>${integrationOutputDirectory}</targetPath>
<excludes>
<exclude>**/*</exclude>
</excludes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>

Resources