0

I have a multi-module project, with a structure like this:

project structure

Then, I try to execute single integration test that is located in the pollen-reports-framework module, as below:

mvn test -Dtest="com.jspollen.reports.resource.ReportResourceIntegrationTest"

It chugs along nicely (or so it seems), executing the required test:

[INFO] Results:
[INFO] 
[INFO] Tests run: 44, Failures: 0, Errors: 0, Skipped: 0

, but then it tries to run the same test from another module and keels over:

[INFO] pollen-service-reports ............................. SUCCESS [  1.607 s]
[INFO] pollen-reports-framework ........................... SUCCESS [ 30.620 s]
[INFO] pollen-reports-askpollen ........................... FAILURE [  0.444 s]
[INFO] pollen-reports-homepagestats ....................... SKIPPED
[INFO] pollen-reports-keymeasures ......................... SKIPPED
[INFO] pollen-reports-customerprofile ..................... SKIPPED
[INFO] pollen-reports-kpitree ............................. SKIPPED
[INFO] pollen-reports-contributionbykpi ................... SKIPPED
[INFO] pollen-reports-productassociation .................. SKIPPED
[INFO] pollen-reports-contributionbyuserdefined ........... SKIPPED
[INFO] pollen-reports-rangeoptimiser ...................... SKIPPED
[INFO] pollen-reports-promotionscalendar .................. SKIPPED
[INFO] pollen-reports-repeatpurchase ...................... SKIPPED
[INFO] pollen-reports-crossshop ........................... SKIPPED
[INFO] pollen-reports-npdcalendar ......................... SKIPPED
[INFO] pollen-reports-customerjourney ..................... SKIPPED
[INFO] pollen-reports-controlstoreselector ................ SKIPPED
[INFO] pollen-reports-productswitching .................... SKIPPED
[INFO] pollen-reports-npdbenchmark ........................ SKIPPED
[INFO] pollen-reports-promotionsoptimisation .............. SKIPPED
[INFO] pollen-reports-rangingtree ......................... SKIPPED
[INFO] pollen-reports-gmandckeymeasures ................... SKIPPED
[INFO] pollen-reports-gmandccustomerprofile ............... SKIPPED
[INFO] pollen-reports-app ................................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  33.141 s
[INFO] Finished at: 2022-06-24T17:09:43+01:00
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "artifactory" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project pollen-reports-askpollen: No tests were executed!  (Set -DfailIfNoTests=false to ignore this error.) -> [Help 1]

The errror suggests it tries to run the test in the project pollen-reports-askpollen, which is not where it is.

How can I avoid the below error and get a sensible test run report for a perfectly well executed test in the above set-up?

Nestor Milyaev
  • 5,845
  • 2
  • 35
  • 51
  • 1
    The first thing: Running integration tests should be handled by maven-failsafe-plugin and not by maven-surefire-plugin. Furthermore you are using very old version of the plugins...furthermore the error output contains the solution. Add `-DfailIfNoTests=false` ... – khmarbaise Jun 24 '22 at 17:16

1 Answers1

0

Apparently this question has already been answerered:

maven :: run only single test in multi-module project

And the trick is to provide the module name as in

mvn test -Dtest=testname -pl subproject, which in my case was

mvn test -Dtest="com.jspollen.reports.resource.ReportResourceIntegrationTest" -pl pollen-reports-framework

Feel free to close this as duplication, although slightly different title for this question may help someone google the answer with different keywords.

Nestor Milyaev
  • 5,845
  • 2
  • 35
  • 51