In case you are ready to make you own plugin, it is relatively easy.

https://github.com/apache/maven-surefire/tree/master/surefire-report-parser/src/main/java/org/apache/maven/plugins/surefire/report
contains the code on how the test report is parsed. I could not find proper
XSD schema for the structure, maybe it does not exist, since I could not
find any references to such a thing.
The writing happens for example here
https://github.com/apache/maven-surefire/blob/b9b2381a3dba6574bb69bd91d45fe0edea29c779/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java#L418

So, you can just run the tests with -DtestFailureIgnore=true, and the make
your plugin run at the end of the build, parse the result and fail the
build if needed.

Any test publishers in CI systems such as the Jenkins Junit plugin will
find all the test reports generated and are able to publish them.

Also in Jenkins you can also easily fail the build using the Junit plugin,
see https://stackoverflow.com/a/57481054. In that case you don't even need
a custom plugin. So be sure to check what kind of functions the CI system
you use provides here.


su 6. helmik. 2022 klo 14.08 Tibor Digana (tibordig...@apache.org)
kirjoitti:

> Alexander, all I wanted to say is to discuss the xxxAtEnd as a Maven
> pattern.
> Is it what we really want to have in Maven?
> Last time we discussed it we said that it was a workaround.
> It should not be a problem to implement in Surefire but it might be an
> internal issue and we should avoid it. So let's discuss this pattern in
> general on the ML apart of the target in a concrete plugin.
>
> On Sun, Feb 6, 2022 at 7:46 AM Alexander Kriegisch <
> alexan...@kriegisch.name>
> wrote:
>
> > Actually, I am not sure I want to compare with Install and Deploy
> > plugin, but because you were mentioning them: 'installAtEnd' and
> > 'deployAtEnd' are blessings IMO, and they are cornerstones of my work,
> > because they help to avoid half-installed and - even worse -
> > half-deployed multi-module projects which would lead to inconsistencies
> > in repositories and might be hard to rectify in remote repositories,
> > "burning" release numbers unnecessarily.
> >
> > Back to the topic at hand: Having a way to run all tests for a
> > multi-module project which would build and package perfectly fine when
> > skipping tests, i.e. not either forcing testing to stop for dependent
> > projects (skipping tests there) or making the build falsely report
> > success in the end, is a perfectly valid use case. Who would not like to
> > have that? Creating a report for all failing tests without cheating the
> > build result to be successful would simply be useful.
> >
> > --
> > Alexander Kriegisch
> > https://scrum-master.de
> >
> >
> > Tibor Digana schrieb am 06.02.2022 01:45 (GMT +07:00):
> >
> > > It is basically the same feature known in the maven-deploy-plugin
> > >
> >
> https://maven.apache.org/plugins/maven-deploy-plugin/deploy-mojo.html#deployAtEnd
> > >
> > > Not sure if the command
> > > mvn deploy -DdeployAtEnd
> > > would fail to deploy dependent modules if the first module fails.
> > >
> > > We discussed this feature some time and we said that these features
> > > xxxAtEnd are a hack.
> > > The question is regarding Maven 4 and Maven 5.
> > >
> > >
> > >
> > >
> > >
> > > On Sat, Feb 5, 2022 at 5:27 AM Alexander Kriegisch <
> > alexan...@kriegisch.name>
> > > wrote:
> > >
> > >> I know that this probably is a classic question, because there
> suggested
> > >> answers on Stack Overflow (and maybe also somewhere here in this
> mailing
> > >> list), but I did not found anything satisfying the following criteria:
> > >>
> > >>   1. Run all Surefire tests, if compilation succeeds, also those of
> > >>      dependent modules, even if there are tests with failurer or
> errors.
> > >>      (We leave Failsafe out of the picture for now for simplicity's
> > >>      sake, but basically the same would apply to Failsafe tests for
> > >>      modules which can be compiled and packaged, despite failing
> > >>      Surefire tests.)
> > >>
> > >>   2. Fail the multi-module build in the end for all modules with
> failing
> > >>      tests.
> > >>
> > >> I know there is '-fae', but it skips modules depending on ones with
> test
> > >> failures.
> > >>
> > >> I know there is '-fn', but it falsely makes the whole build pass.
> > >>
> > >> I know that the Maven build lifecycle is based on module dependencies
> > >> and that dependent modules usually should not be built, if a
> dependency
> > >> fails to build. But OTOH, the same build would pass with
> '-DskipTests',
> > >> and the requirement that artifacts be compiled and packaged and
> > >> dependent modules built, because those artifacts can in fact be
> compiled
> > >> and packaged, makes practical sense. Basically, the user wants test
> > >> failures reported correctly, but still make sure that as many tests as
> > >> possible are being run.
> > >>
> > >> Is there any way to achieve that?
> > >> --
> > >> Alexander Kriegisch
> > >> https://scrum-master.de
> > >>
> > >> ---------------------------------------------------------------------
> > >> To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> > >> For additional commands, e-mail: users-h...@maven.apache.org
> > >>
> > >>
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscr...@maven.apache.org
> > For additional commands, e-mail: users-h...@maven.apache.org
> >
> >
>

Reply via email to