How to run testNG tests using Maven POM file - maven

I have a Selenium project, using Maven and TestNG.
I have tried several different methods of getting my tests to run with a Maven command (I'm using the sure fire plugin).
When I run Maven the tests do not run. There are no errors.
Has anyone got a good example or a tutorial that I could follow to get my test to run when I use mvn test?
Thanks in advance.
Here is the output:
C:\**************>mvn test
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Building Unnamed - **************:**************:jar:1.0
[INFO] task-segment: [test]
[INFO] ------------------------------------------------------------------------
[INFO] [resources:resources]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] Copying 4 resources
[INFO] [compiler:compile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [resources:testResources]
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources,
i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\**************\src\test\res
ources
[INFO] [compiler:testCompile]
[INFO] Nothing to compile - all classes are up to date
[INFO] [surefire:test]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESSFUL
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Tue Oct 02 15:14:10 BST 2012
[INFO] Final Memory: 16M/38M
[INFO] ------------------------------------------------------------------------
And the surefire configuration from my POM file:
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<encoding>iso-8859-1</encoding>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<suiteXmlFiles>
<suiteXmlFile>src/main/test_suites/local/***_Test.xml</suiteXmlFile>
</suiteXmlFiles>
</configuration>
</plugin>

Take a look at this Maven Using TestNG site.
Basically all you have to do is adding a dependency to the TestNG.
<dependencies>
[...]
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>6.3.1</version>
<scope>test</scope>
</dependency>
[...]
</dependencies>
The default includes in maven-surefire-plugin are:
<includes>
<include>**/Test*.java</include>
<include>**/*Test.java</include>
<include>**/*TestCase.java</include>
</includes>
That means that if the name of your test classes does not match the above include patterns then maven-surefire-plugin will not find them and run them.
You can change/add files to include by adding these to the plugin configuration.

Related

maven-compiler-plugin: change <outputDirectory> per execution

situation
I have XML files which I need to deal with in my GUI (JavaXF) and in my JavaStoredProcedures in my oracle12c database.
In the GUI I want to use properties bindings.
So I configured the maven-jaxb2-plugin to generate the sources with properties.
The database on the other hand does not support Java8 therefore is configured a second execution for the maven-jaxb2-plugin to generate the sources without properties in a different folder ending up with two folders containing the same Java-classes in the same packages in different folders.
So what I have now looks like this:
project
\-target
\-generated-sources
+-java7
| \-package.with.java.files
| \-Java7-compilabe-sources*
\-java8
\-package.with.java.files
\-Java8-compilabe-sources*
What I want to do next is to compile the two folders target/generated-sources/java7 and target/generated-sources/java8 to different output folders target/java7/classes and target/java8/classes respectively within different executions of the maven-compiler-plugin.
But I'm not able to change the output directory of the maven-compiler-plugin for a single execution.
This is my current configuration of the maven-compiler-plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<encoding>ISO-8859-1</encoding>
</configuration>
<executions>
<execution>
<id>java8</id>
<configuration>
<source>1.8</source>
<target>1.8</target>
<executable>${jdk-1.8}/bin/javac</executable>
<compilerVersion>1.8</compilerVersion>
<sourceDirectory>${project.build.directory}/generated-sources/java8</sourceDirectory>
<outputDirectory>${basedir}/target/java8/classes</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
But from the maven output it looks like it does not respect either one of <sourceDirectory> nor <outputDirectory>:
[INFO] ------------------------------------------------------------------------
[INFO] Building MyProject 6.0.5
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) # MyProject ---
[INFO] Deleting /ProjectRoot/target
[INFO]
[INFO] --- maven-jaxb2-plugin:0.13.1:generate (Java8) # MyProject ---
[INFO] Up-to-date check for source resources [[file:/ProjectRoot/src/main/xsd/parad.xsd, file:/ProjectRoot/src/main/xjb/bindings.xml, file:/ProjectRoot/pom.xml]] and target resources [[]].
[INFO] Sources are not up-to-date, XJC will be executed.
[INFO] Episode file [/ProjectRoot/target\generated-sources\java8\META-INF\sun-jaxb.episode] was augmented with if-exists="true" attributes.
[INFO]
[INFO] --- maven-jaxb2-plugin:0.13.1:generate (Java7) # MyProject ---
[INFO] Up-to-date check for source resources [[file:/ProjectRoot/src/main/xsd/parad.xsd, file:/ProjectRoot/src/main/xjb/bindings.xml, file:/ProjectRoot/pom.xml]] and target resources [[]].
[INFO] Sources are not up-to-date, XJC will be executed.
[INFO] Episode file [/ProjectRoot/target\generated-sources\java7\META-INF\sun-jaxb.episode] was augmented with if-exists="true" attributes.
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # MyProject ---
[WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO] Copying 1 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # MyProject ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 114 source files to /ProjectRoot/target\classes
findings
the compiler pluging does not show the execution ID (as the maven-jaxb2-plugin does)
the compiler pluging compiles both target/generated-sources/java7 and target/generated-sources/java8 (each contains 57 *.java files) although <sourceDirectory> is given in execution/config
the compiler pluging compiles to target/classes although <outputDirectory> is given in execution/config
question
how do I force maven to compile each of target/generated-sources/java7 and target/generated-sources/java8 to its own target folder separately?
additional info
$ mvn --version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T13:57:37+02:00)
I solved the problem by usting the maven-antrun-plugin.
first I turend off compilation by excluding all files:
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<verbose>true</verbose>
<fork>true</fork>
<encoding>ISO-8859-1</encoding>
<source>1.8</source>
<target>1.8</target>
<executable>${jdk-1.8}/bin/javac</executable>
<compilerVersion>1.8</compilerVersion>
<excludes>
<exclude>**/*.*</exclude>
</excludes>
</configuration>
I also turned of the maven-jar-plugin
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>default-jar</id>
<phase>never</phase>
<configuration>
<finalName>unwanted</finalName>
<classifier>unwanted</classifier>
</configuration>
</execution>
</executions>
then I configured separate executions in the maven-antrun-plugin to compile eache source folder and create the separate jars.
what's left is to configure the maven-deploy-plugin so that the two jars (and their source jars) are correctly placed in the maven repository so that they can be fetched as dependencies.

yuicompressor-maven-plugin not working at mvn install or designated phase

Here is the maven pom.xml build session
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<compilerArgument></compilerArgument>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>${project.artifactId}</warName>
<warSourceExcludes>**/*.js,**/*.css</warSourceExcludes>
</configuration>
</plugin>
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>yuicompressor-maven-plugin</artifactId>
<version>1.5.1</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>compress</goal>
</goals>
</execution>
</executions>
<configuration>
<encoding>UTF-8</encoding>
<jswarn>false</jswarn>
<nosuffix>true</nosuffix>
<linebreakpos>-1</linebreakpos>
<excludes>
<exclude>**/*.min.js</exclude>
<exclude>**/*.min.css</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
and when run mvn install or mvn pre-package(which is the designated phase ) there is no yuicompressor-maven-plugin working log.
$mvn install
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building gif-www 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) # gif-www ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # gif-www ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) # gif-www ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory /home/ximing/work/gifmiao/gif-www/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) # gif-www ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.17:test (default-test) # gif-www ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-war-plugin:2.2:war (default-war) # gif-www ---
[INFO] Packaging webapp
[INFO] Assembling webapp [gif-www] in [/home/ximing/work/gifmiao/gif-www/target/gif-www-1.0-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [/home/ximing/work/gifmiao/gif-www/src/main/webapp]
[INFO] Webapp assembled in [170 msecs]
[INFO] Building war: /home/ximing/work/gifmiao/gif-www/target/gif-www.war
[INFO] WEB-INF/web.xml already added, skipping
but using mvn yuicompressor:compress can get the yuicompressor log shows that the plugin is working.
and I also don't know how to package the compressed css and js to the war file (with the same file name cause I don't want to tweak the include code in html template). Have been working on this about a whole day, someone give me a clue?
You are only defining, but not executing your plugin by putting the configuration between the tag.
See also https://stackoverflow.com/a/10483284/1110843

2 exec-maven-plugin defined in POM - not working

I have two Java main classes that I need executed during different parts of a build process. One needs to execute ALWAYS as part of my standard build process during the generate-sources phase. The other needs to execute as part of a profile, but that profile should be execute at the end of the process-classes phase, which should also include the generate-sources phase prior to that.
I was able to get the first plugin working correctly during the generate-sources phase of the standard build process:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.example.MySourceGenerator</mainClass>
</configuration>
</plugin>
However when I added a second instance of the same plugin to the profile, the plugin defined as part of the standard build is no longer invoked during my build process, resulting in compile errors. This is the configuration in the profile:
<profiles>
<profile>
<id>initSchema</id>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<phase>process-classes</phase>
<goals>
<goal>java</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>com.example.SomeOtherClass</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
This is what I run on the command line: mvn process-classes -PinitSchema. What is wrong with my configuration? I am expecting both plugins to execute during their respective phases.
To clarify: the first exec-maven-plugin generates sources and the second one initialized my DB schema.
EDIT:
Here is the output
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building ABC Web Application 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
...
[INFO] --- build-helper-maven-plugin:1.8:add-source (add-source) # web-app ---
[INFO] Source directory: /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/generated-sources/msg added.
[INFO]
[INFO] --- maven-processor-plugin:2.0.6:process (process) # web-app ---
[INFO] Source directory: /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/generated-sources/apt added
[INFO] javac option: -cp
...
[INFO] javac option: -proc:only
[INFO] javac option: -processor
[INFO] javac option: com.company.vocab.generator.VocabAnnotationProcessor,org.hibernate.jpamodelgen.JPAMetaModelEntityProcessor
[INFO] javac option: -d
[INFO] javac option: /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/classes
[INFO] javac option: -s
[INFO] javac option: /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/generated-sources/apt
[INFO] diagnostic Note: Hibernate JPA 2 Static-Metamodel Generator 1.2.0.Final
[INFO] diagnostic /Users/wendyschmitz/projects/ae/abc-proj/web-app/src/main/java/com/company/service/dto/AccountDto.java:5: error: cannot find symbol
import com.telos.xacta.util.Messages;
...
(more similar messages)
[INFO]
[INFO] --- jaxb2-maven-plugin:1.5:xjc (default) # web-app ---
[INFO] Generating source...
[INFO] parsing a schema...
[INFO] compiling a schema...
...
[INFO] --- maven-resources-plugin:2.4.3:resources (default-resources) # web-app ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 16 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) # web-app ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 281 source files to /Users/wendyschmitz/projects/ae/abc-proj/web-app/target/classes
[INFO] -------------------------------------------------------------
...
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /Users/wendyschmitz/projects/ae/abc-proj/web-app/src/main/java/com/company/service/dto/ProjectHeadDto.java:[4,28] cannot find symbol
symbol: class Messages
location: package com.company.util
...
(more similar errors)
...
[INFO] 29 errors
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.817s
[INFO] Finished at: Thu Aug 01 20:49:07 EDT 2013
[INFO] Final Memory: 31M/282M
[INFO] ------------------------------------------------------------------------
Give both the execution blocks a different id, because now they both use the default id and so one will overwrite the other.

How can I specify an ant target to run during the release:prepare goal?

When using the maven release plugin I want to do some pre-work (via an ant tast) as part of the release build with the assurance that the same code base is used (so no commits sneak in between). I have an ant task that I want to call to do this, but I'm having the following issue:
inside my pom file:
<configuration>
<preparationGoals>antrun:run -Dtarget=${antTaskJarBuildXML} clean verify</preparationGoals>
</configuration>
where ${antTaskJarBuildXML} is:
<target><ant antfile=\"../build.xml\" target=\"iv_dependency_build\" /></target>
When I run release:perform this is the log:
...
[INFO] Not generating release POMs
[INFO] Executing goals 'antrun:run -Dtarget="<target><ant antfile=\"../build.xml\" target=\"iv_dependency_build\" /></target>" clean verify'...
[WARNING] Maven will be executed in interactive mode, but no input stream has been configured for this MavenInvoker instance.
[INFO] [INFO] Scanning for projects...
[INFO] [WARNING]
[INFO] [WARNING] Some problems were encountered while building the effective model for com.xactsites:iv:war:12.12.4.9
[INFO] [WARNING] The expression ${version} is deprecated. Please use ${project.version} instead.
[INFO] [WARNING]
[INFO] [WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[INFO] [WARNING]
[INFO] [WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[INFO] [WARNING]
[INFO] [INFO]
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [INFO] Building iv 12.12.4.9
[INFO] [INFO] ------------------------------------------------------------------------
[INFO] [WARNING] The artifact javax.xml:jaxrpc:jar:1.1 has been relocated to javax.xml:jaxrpc-api:jar:1.1
[INFO] [INFO]
[INFO] [INFO] --- maven-antrun-plugin:1.7:run (default-cli) # iv ---
[INFO] [INFO] No ant target defined - SKIPPED
[INFO] [INFO]
[INFO] [INFO] --- maven-clean-plugin:2.4.1:clean (default-clean) # iv ---
[INFO] [INFO] Deleting C:\dev\apps\iv\target
[INFO] [INFO]
...
And as shown in the log, I am told that no target is specified. I followed what I understood from the ant run documentation
Am I missing something in how to pass in the target name?
Is this the best approach?
Is it a matter of escaping that I am missing? I'm on windows and this is the actual value defined for the xml (${antTaskJarBuildXML}):
"<target><ant antfile=\"../build.xml\" target=\"iv_dependency_build\" /></target>"
EDIT
#carlspring has given some great feedback (+1 on his answer), however, due to the nature of the problem where not everything is mavenized I couldn't get this working. Maven is expecting to be in control of the whole release process, but I need to perform an ant task (which creates dependencies needed for the build in question) beforehand. I also need to be assured that this prework task and the regular build are built against the same git tag/hash. My current solution is to sequentially do the steps that the release plugin would perform as discussed here. Through this I can create a git tag then do the maven build against that same git tag. If there are any better ideas out there please contribute!
My suggestions would be for you to define a profile and have your ant-run definition in it.
The release plugin forks, meaning your command-line args will be ignored.
UPDATE:
Try this:
<?xml version="1.0" encoding="UTF-8"?>
<project ...>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.3.2</version>
<executions>
<execution>
<id>execute-prepare</id>
<!-- Set up your Ant stuff here -->
<goals>
<goal>prepare</goal>
</goals>
<configuration>
<!-- If you have args specific for your release, put them here: -->
<arguments>-Pant-run-release</arguments>
<releaseProfiles>ant-run-release</releaseProfiles>
<mavenExecutorId>forked-path</mavenExecutorId>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>ant-run-release</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>execute-something</id>
<!-- Set up your Ant stuff here -->
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

use of build-helper-maven-plugin and multi module skip the test

I use the build-helper-maven-plugin for a legacy project with a non standard tree folder.
I use it this way :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/firstmodule/src</source>
<source>${basedir}/secondmodule/src</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>${basedir}/firstmodule/tests</source>
<source>${basedir}/secondmodule/tests</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
It works correctly if I launch mvn install on the root of the project, tests passed.
However, this project is a submodule in a bigger project.
If I launch mvn install in the root folder of the parent project, maven don't execute the test.
it seems to work but surefire do not detect any test :
[INFO] Building MyLegacyProject
[INFO] task-segment: [clean, install]
[INFO] ------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] Deleting directory C:\DEV\perforce\1992\depot\MyProject\release\BUG_FIXING\MyLegacyProject\target
[INFO] [build-helper:add-source {execution: add-source}]
[INFO] Source directory: C:\DEV\perforce\1992\depot\MyProject\release\BUG_FIXING\MyLegacyProject\firstmodule\src added.
[INFO] Source directory: C:\DEV\perforce\1992\depot\MyProject\release\BUG_FIXING\MyLegacyProject\secondmodule\src added.
[INFO] [build-helper:add-test-source {execution: add-test-source}]
[INFO] Test Source directory: C:\DEV\perforce\1992\depot\MyProject\release\BUG_FIXING\MyLegacyProject\firstmodule\tests added.
[INFO] Test Source directory: C:\DEV\perforce\1992\depot\MyProject\release\BUG_FIXING\MyLegacyProject\secondmodule\tests added.
[debug] execute contextualize
[INFO] [resources:resources {execution: default-resources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 40 resources
[INFO] Copying 40 resources
[WARNING] While downloading com.sun.xml:saaj-impl:1.3
This artifact has been relocated to com.sun.xml.messaging.saaj:saaj-impl:1.3.
[WARNING] While downloading javax.xml:jaxb-api:2.1
This artifact has been relocated to javax.xml.bind:jaxb-api:2.1.
[INFO] [compiler:compile {execution: default-compile}]
[INFO] Compiling 752 source files to C:\DEV\perforce\1992\depot\MyProject\release\BUG_FIXING\MyLegacyProject\target\classes
[debug] execute contextualize
[INFO] [resources:testResources {execution: default-testResources}]
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 2 resources
[INFO] Copying 34 resources
[INFO] [compiler:testCompile {execution: default-testCompile}]
[INFO] Compiling 15 source files to C:\DEV\perforce\1992\depot\MyLegacyProject\release\BUG_FIXING\MyLegacyProject\target\test-classes
[INFO] [surefire:test {execution: default-test}]
[INFO] Surefire report directory: C:\DEV\perforce\1992\depot\MyLegacyProject\release\BUG_FIXING\MyLegacyProject\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running TestSuite
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.381 sec
Results :
Tests run: 0, Failures: 0, Errors: 0, Skipped: 0
any idea how to made this work ?
Try to launch mvn with the debug mode (-X) to view if properties used by surefire are correct for your tree folder.
Are you using Maven 3 ? ${basedir} is recognized only by maven 3 (and silently ignored by maven 2 :( )
How do you understand the basedir usage ? It is the directory path of the POM where the build started. Thus it will be either the path to the parent project directory or one of its modules depending where you are launching the build from. In the second case the path will be wrong. I suppose you expected to have always the path to the root directory of your project ?
Ok I found it !!!
Somebody had the same problem :
https://stackoverflow.com/a/6925096/242658
However it was really hard to figure it.
It was not related to build-helper-maven-plugin and I don't know why I had not this problem in single module mode.
I used powermock and powermock that pulled in TestNG. And with testng my tests are not detected by surefire. So I had to exclude testng:
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-mockito-release-full</artifactId>
<version>1.4.9</version>
<classifier>full</classifier>
<exclusions>
<exclusion>
<artifactId>powermock-module-testng</artifactId>
<groupId>org.powermock</groupId>
</exclusion>
</exclusions>
</dependency>

Resources