Maven - Configuring Run Job Execution Always
In my project POM file, I need to set up a post run step . those. after running the unit tests, post exec. the task will parse the testng-xml-report and generate a statistics page. The report will be generated by a separate bank. This Jar will be called in the
POM phase .
But the current problem is that for a test success scenario in a phase,
it will call Jar and work correctly. For failure case, an xml report will be generated, but since the phase is
not running, it will not continue the phase
So that I can point out that should run the event the maven-the exec-plugin the exec to invoke Jar, regardless of whether the phase
is a success or not.
source to share
The correct solution for this scenario is not to skip tests. The tests should record a failure (eg in an XML report), but the runner should return "success" to Maven.
For Surefire, you can achieve this with
EDIT You can put this in your POM to activate it permanently.
But if you call maven for different purposes, the results may be unwanted. For example, for
, you probably want the process to stop when there are testing errors.
To fix this, you have two options:
- Write a script that calls Maven with the required parameters to generate a test report
- Move the parameter to profile
[EDIT] Details about option # 1: You can write a shell script that starts Maven with
to generate reports.
Then you need a utility that can find XML reports and check if there are any errors in it. If you are using Java to do this, call
if you find errors. If you prefer the command line, use XMLStarlet to run an XML query and a tool such as
to find XML files. If you need help, please post new questions.
Call this utility after Maven in your shell script with
util || exit 1
- this will stop the shell script with an error code
if the utility encounters an error.
Use this script to build instead of the embedded Maven runner.
source to share