You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by "swapsapar@gmail.com" <sw...@gmail.com> on 2012/01/26 20:36:39 UTC

How to parse JUnit report xml that causes build to pass/fail

Hi,
I have been using Maven 2.2.1 for a while now and have used it successfully
for multiple projects so far. I must say it is one the most sophisticated
build system that is well thought and comprehensive in nature.

I have 'maven'ized a project to a certain extent but we have an outstanding
issue that is troubling developers. Take a deep breath as I explain this
problem below...

I'm trying to follow beautiful principal of maven lifecycle thoroughly and
performing unit tests in 'test' phase and integration tests in
'integration-test' phase. Since its a webapp (war), I start/stop server
during pre/post integration-phases. During this 'integration-test', I run a
series of Java JUnit tests that asserts different features of server. If one
of the test fails, the main maven build comes out saying..
[ERROR] BUILD FAILURE
[INFO]
------------------------------------------------------------------------
[INFO] There are test failures.

And this is very useful for me and treasure this logic very much.

Life is good so far and here comes the problem. Along with these Java based
JUnit integration tests, I also have some other non-Java, non-JUnit based
tests (actually phantomjs/Jasmine) which validates some other aspects of
server. And this external test executable "exports" its test results in a
xml file that is compatible with JUnit, described here
http://www.junit.org/node/399. Note that this is NOT a junit test and maven
runtime does not know abt how the test are ran, rather external test exec
just exports a xml file that is fully JUnit result compatible. And if there
is a failure reported in this exported xml file, I need to cause the build
to fail like above. That means I want maven to parse this report xml, treat
it similar to any other tests and cause build to fail. Currently my build
says 'Successful' even if there are test failures in the exported xml file.

Note: Similar feature exists in the CI tools like Jenkins/TeamCity but its
not something that developer can use locally. I wish simple 'mvn clean
install' to work with my exported xml file.

Note: Surefire report-only goal does generates the reports with all the test
xml files I have and shows the test failure in the HTML report. But this
does not cause final build to fail upon test failures.

Q. Is there a way to tell maven (via plugin or something) that look for test
failures in the test xml file and declare the build pass/fail?

Appreciate any help/clues/suggestions.
Thanks you.
Deep 'Maven'er :)

 

--
View this message in context: http://maven.40175.n5.nabble.com/How-to-parse-JUnit-report-xml-that-causes-build-to-pass-fail-tp5433750p5433750.html
Sent from the Maven - Users mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org


Re: How to parse JUnit report xml that causes build to pass/fail

Posted by Stephen Connolly <st...@gmail.com>.
Sorry, my bad. I mis-understood.

You can just write your own plugin, very easy to do

On 26 January 2012 22:58, Stephen Connolly
<st...@gmail.com>wrote:

> Please take a look at the maven-failsafe-plugin, it is a version of
> surefire to cover your exact use case
>
>
> On 26 January 2012 19:36, swapsapar@gmail.com <sw...@gmail.com> wrote:
>
>> Hi,
>> I have been using Maven 2.2.1 for a while now and have used it
>> successfully
>> for multiple projects so far. I must say it is one the most sophisticated
>> build system that is well thought and comprehensive in nature.
>>
>> I have 'maven'ized a project to a certain extent but we have an
>> outstanding
>> issue that is troubling developers. Take a deep breath as I explain this
>> problem below...
>>
>> I'm trying to follow beautiful principal of maven lifecycle thoroughly and
>> performing unit tests in 'test' phase and integration tests in
>> 'integration-test' phase. Since its a webapp (war), I start/stop server
>> during pre/post integration-phases. During this 'integration-test', I run
>> a
>> series of Java JUnit tests that asserts different features of server. If
>> one
>> of the test fails, the main maven build comes out saying..
>> [ERROR] BUILD FAILURE
>> [INFO]
>> ------------------------------------------------------------------------
>> [INFO] There are test failures.
>>
>> And this is very useful for me and treasure this logic very much.
>>
>> Life is good so far and here comes the problem. Along with these Java
>> based
>> JUnit integration tests, I also have some other non-Java, non-JUnit based
>> tests (actually phantomjs/Jasmine) which validates some other aspects of
>> server. And this external test executable "exports" its test results in a
>> xml file that is compatible with JUnit, described here
>> http://www.junit.org/node/399. Note that this is NOT a junit test and
>> maven
>> runtime does not know abt how the test are ran, rather external test exec
>> just exports a xml file that is fully JUnit result compatible. And if
>> there
>> is a failure reported in this exported xml file, I need to cause the build
>> to fail like above. That means I want maven to parse this report xml,
>> treat
>> it similar to any other tests and cause build to fail. Currently my build
>> says 'Successful' even if there are test failures in the exported xml
>> file.
>>
>> Note: Similar feature exists in the CI tools like Jenkins/TeamCity but its
>> not something that developer can use locally. I wish simple 'mvn clean
>> install' to work with my exported xml file.
>>
>> Note: Surefire report-only goal does generates the reports with all the
>> test
>> xml files I have and shows the test failure in the HTML report. But this
>> does not cause final build to fail upon test failures.
>>
>> Q. Is there a way to tell maven (via plugin or something) that look for
>> test
>> failures in the test xml file and declare the build pass/fail?
>>
>> Appreciate any help/clues/suggestions.
>> Thanks you.
>> Deep 'Maven'er :)
>>
>>
>>
>> --
>> View this message in context:
>> http://maven.40175.n5.nabble.com/How-to-parse-JUnit-report-xml-that-causes-build-to-pass-fail-tp5433750p5433750.html
>> Sent from the Maven - Users mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
>> For additional commands, e-mail: users-help@maven.apache.org
>>
>>
>

Re: How to parse JUnit report xml that causes build to pass/fail

Posted by Stephen Connolly <st...@gmail.com>.
Please take a look at the maven-failsafe-plugin, it is a version of
surefire to cover your exact use case

On 26 January 2012 19:36, swapsapar@gmail.com <sw...@gmail.com> wrote:

> Hi,
> I have been using Maven 2.2.1 for a while now and have used it successfully
> for multiple projects so far. I must say it is one the most sophisticated
> build system that is well thought and comprehensive in nature.
>
> I have 'maven'ized a project to a certain extent but we have an outstanding
> issue that is troubling developers. Take a deep breath as I explain this
> problem below...
>
> I'm trying to follow beautiful principal of maven lifecycle thoroughly and
> performing unit tests in 'test' phase and integration tests in
> 'integration-test' phase. Since its a webapp (war), I start/stop server
> during pre/post integration-phases. During this 'integration-test', I run a
> series of Java JUnit tests that asserts different features of server. If
> one
> of the test fails, the main maven build comes out saying..
> [ERROR] BUILD FAILURE
> [INFO]
> ------------------------------------------------------------------------
> [INFO] There are test failures.
>
> And this is very useful for me and treasure this logic very much.
>
> Life is good so far and here comes the problem. Along with these Java based
> JUnit integration tests, I also have some other non-Java, non-JUnit based
> tests (actually phantomjs/Jasmine) which validates some other aspects of
> server. And this external test executable "exports" its test results in a
> xml file that is compatible with JUnit, described here
> http://www.junit.org/node/399. Note that this is NOT a junit test and
> maven
> runtime does not know abt how the test are ran, rather external test exec
> just exports a xml file that is fully JUnit result compatible. And if there
> is a failure reported in this exported xml file, I need to cause the build
> to fail like above. That means I want maven to parse this report xml, treat
> it similar to any other tests and cause build to fail. Currently my build
> says 'Successful' even if there are test failures in the exported xml file.
>
> Note: Similar feature exists in the CI tools like Jenkins/TeamCity but its
> not something that developer can use locally. I wish simple 'mvn clean
> install' to work with my exported xml file.
>
> Note: Surefire report-only goal does generates the reports with all the
> test
> xml files I have and shows the test failure in the HTML report. But this
> does not cause final build to fail upon test failures.
>
> Q. Is there a way to tell maven (via plugin or something) that look for
> test
> failures in the test xml file and declare the build pass/fail?
>
> Appreciate any help/clues/suggestions.
> Thanks you.
> Deep 'Maven'er :)
>
>
>
> --
> View this message in context:
> http://maven.40175.n5.nabble.com/How-to-parse-JUnit-report-xml-that-causes-build-to-pass-fail-tp5433750p5433750.html
> Sent from the Maven - Users mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
> For additional commands, e-mail: users-help@maven.apache.org
>
>

Re: How to parse JUnit report xml that causes build to pass/fail

Posted by Wayne Fay <wa...@gmail.com>.
> runtime does not know abt how the test are ran, rather external test exec
> just exports a xml file that is fully JUnit result compatible. And if there
> is a failure reported in this exported xml file, I need to cause the build
> to fail like above. That means I want maven to parse this report xml, treat
> it similar to any other tests and cause build to fail. Currently my build

Write your own plugin to call your external test and report failures,
either by parsing the xml or some other approach
- or -
Adjust your external test tool so it returns "false" (1) when it has a
failure which Maven should pick up and understand to mean "failure
encountered" and it will fail the build

Wayne

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org