This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin for Android App Development and have Peter Sommerhoff on-line!
See this thread for details.
Win a copy of Kotlin for Android App Development this week in the Kotlin 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
  • Liutauras Vilda
  • Devaka Cooray
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

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: 20345
111
Android Eclipse IDE Linux
  • 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: 20345
111
Android Eclipse IDE Linux
  • 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: 20345
111
Android Eclipse IDE Linux
  • 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.
 
You got style baby! More than this tiny ad:
Programmatically Create PDF Using Free Spire.PDF with Java
https://coderanch.com/wiki/703735/Programmatically-Create-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!