I am trying to follow the guide here to learn to run integration tests which is exactly what we need functionality wise. https://github.com/OpenLiberty/guide-jpa-intro/blob/prod/finish/backendServices
In our org the way things are setup is that we produce a jar file instead of a war file at this phase of the project. Then another unrelated devops project which we do not control over builds the war file from this jar file with various env specific properties and deploys it.
https://github.com/OpenLiberty/guide-jpa-intro/blob/prod/finish/backendServices/pom.xml
<groupId>io.openliberty.guides</groupId>
<artifactId>backendServices</artifactId>
**<packaging>jar</packaging>**
<version>1.0-SNAPSHOT</version>
The question is how do we tell openliberty ideally programmatically to turn the jar file into a war file to deploy the binary and then use it for integration testing ? for e.g. run the below test https://github.com/OpenLiberty/guide-jpa-intro/blob/prod/finish/backendServices/src/test/java/it/io/openliberty/guides/event/EventEntityIT.java
You could use a separate test WAR module which uses your JAR module as a dependency.
This WAR module could include:
src/main/liberty/config/server.xml
)**IT.java
)This shouldn't prevent you from separately building another WAR (e.g. production) through some other DevOps process which ignores this test WAR.
It would also be possible to use the separate test WAR module while keeping the integration test source **IT.java
within the JAR module, if you feel that is a better organization of your overall project. You would want then to configure the failsafe plugin to run IT against the test WAR module deploying the app to the test Liberty server and NOT configure the failsafe plugin to run IT in the context of the JAR module build.
I think it might be better though to include the integration test source within the WAR module since it's using endpoints (e.g. host/port) which are tightly-coupled to the Liberty server. You could use a single "multi-module" Maven project to allow all of the code to be grouped into a single source repository (Git), possibly using Maven "profiles" to control whether to build and execute the IT logic or just to build the JAR dependency (for use by your other DevOps process).