This week's giveaway is in the JDBC forum.
We're giving away four copies of Java Database Connections & Transactions (e-book only) and have Marco Behler on-line!
See this thread for details.
Win a copy of Java Database Connections & Transactions (e-book only) this week in the JDBC forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Junit Maven XML report  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am executing Junit Test with Maven. I am actually looking for a clean Junit xml report but the report i am getting contains lots of redundant nodes. Can any one has ever implemented anything like this-
ExpectedXML.PNG
[Thumbnail for ExpectedXML.PNG]
Screen shot of expected xml
ActualXMLReport.PNG
[Thumbnail for ActualXMLReport.PNG]
Screen shot of Actually generated XML
 
Bartender
Posts: 20775
124
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Rahul!

What do you mean by "redundant"?

Are you referring to the detailed stack traces? Because if a test fails, developers are going to need as much information as they can get about why it failed.

The Maven junit mojo does have other report formats, including the ability to render HTML with zoom capabilities, although I forget the name of the facility that it uses.

I'm adding this question to the Maven forum, since it's really about Maven more than it is about junit.
 
Rahul manish
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,
We need a Junit report in a way where we can just read the tescase name,Status and our customized error message (in case of failure). So, I need to remove all stack trace info and also if you check closely there is a property node also appear in every Junit report, I need to remove that as well.
 
Tim Holloway
Bartender
Posts: 20775
124
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can check the options, but considering how much customization you want done, I suspect that the only way to get what you want is to write your own Maven mojo. You can either make it reformat the XSL itself or make it run XSLT, whichever is easier.

Mojos are simply JavaBeans that conform to Maven's requirements. You should, however read FROM the original XML and output TO a new directory and not simply replace the original XML. That not only violates the spirit of how Maven works, but can make it harder to debug the mojo.

These days I run Maven inside Jenkins and the defaults make nice online reports with red/green indicators that make it easy to zoom in on failing tests.
 
Rahul manish
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tim,
Not sure how to do this. Even I couldn't find something using which i can create a template of my XML report and use it whenever any report generates.
 
Tim Holloway
Bartender
Posts: 20775
124
Android Eclipse IDE Java Linux Redhat Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I rate that as a medium-difficulty programming job. To customize the Maven output, you need to know how to design and code a Maven mojo plugin (they're based on JavaBeans) and you need to know how to use an xslt translator such as xalan. Or, alternatively, parse and reformat the data using brute-force java code with maybe something like JAXB.

The standard formatter used by Maven is Surefire, and since it's open source (as is Maven) you could always look to it for inspiration.
 
Popeye has his spinach. I have this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!