javaee-samples/javaee7-samples

Tests fail when run with maven-failsafe-plugin

thomas-mc-work opened this issue · 3 comments

Hello,

I have picked a sub project (jpa-jpa-converter) and renamed the test file form EmployeeRepositoryTest to EmployeeRepositoryIT. Thus it will be driven by the maven-failsafe-plugin with the command failsafe:integration-test.

First question is: Why isn't that the default in the whole repository? Isn't integration testing the goal of the whole thing? I would expect all integration tests to be run seperated from my normal unit tests.

Second Question: When I now start the tests explicitly then I receive an error that is stating almost nothing to me:

cd /home/thomas/ablage/javaee7-samples/jpa/jpa-converter; JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 M2_HOME=/home/thomas/software/apache-maven-3 /home/thomas/software/apache-maven-3/bin/mvn -Pwildfly-managed-arquillian failsafe:integration-test
Scanning for projects...

Some problems were encountered while building the effective model for org.javaee7:jpa-jpa-converter:jar:1.0-SNAPSHOT
'build.plugins.plugin.version' for org.apache.maven.plugins:maven-surefire-plugin is missing. @ org.javaee7:samples-parent:1.0-SNAPSHOT, /home/thomas/ablage/javaee7-samples/pom.xml, line 468, column 29

It is highly recommended to fix these problems because they threaten the stability of your build.

For this reason, future Maven versions might no longer support building such malformed projects.


------------------------------------------------------------------------
Building Java EE 7 Sample: jpa-converter 1.0-SNAPSHOT
------------------------------------------------------------------------

--- maven-failsafe-plugin:2.19.1:integration-test (default-cli) @ jpa-jpa-converter ---

-------------------------------------------------------
 T E S T S
-------------------------------------------------------
Running org.javaee7.jpa.converter.EmployeeRepositoryIT
Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.561 sec <<< FAILURE! - in org.javaee7.jpa.converter.EmployeeRepositoryIT
org.javaee7.jpa.converter.EmployeeRepositoryIT  Time elapsed: 0.56 sec  <<< ERROR!
org.jboss.arquillian.container.spi.client.container.LifecycleException: Could not start container
Caused by: java.lang.NullPointerException


Results :

Tests in error: 
  EmployeeRepositoryIT.org.javaee7.jpa.converter.EmployeeRepositoryIT » Lifecycle

Tests run: 1, Failures: 0, Errors: 1, Skipped: 0

File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent! The file encoding for reports output files should be provided by the POM property ${project.reporting.outputEncoding}.
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 3.333 s
Finished at: 2016-01-29T09:06:04+01:00
Final Memory: 21M/302M
------------------------------------------------------------------------

So the essence of this is org.jboss.arquillian.container.spi.client.container.LifecycleException: Could not start container Caused by: java.lang.NullPointerException
The same test runs fine when executed by surefire:test.

Ok, I've found the answer to the second question: The configuration is simply targeting for the maven-surefire-plugin. Doing the same for the maven-failsafe-plugin will solve the problem.

Hi, I'm facing the same problem here. When you say "The configuration is simply targeting...": Is this configuration the pom.xml? What changes you've made to make this work? Thanks in advance!

Well, maybe a bit late. But maybe also it could still help someone:

Most probably I search and replaced maven-surefire-plugin for maven-failsafe-plugin int he root pom: https://github.com/javaee-samples/javaee7-samples/blob/master/pom.xml