June 28, 2006

Improving MbUnit’s HTML report with JavaScript

Filed under: Software Blog — marcstober @ 10:23 am

Every morning in my email I get a couple unit test reports generated by MbUnit during our daily (actually nightly) build process. Many of our tests output a lot of logging information, so reading the report takes a lot of scrolling and there’s no way to see at a glance what’s failed.
I realized that MbUnit’s HTML reports are just an MbUnit XML report with an XSL transform. By downloading the MbUnit source code, I was able to get the XSL, modify it with some JavaScript, and do my own transform. Specifically, I added +/- buttons to expand and collapse the details of each test, and Expand All and Collapse All buttons at the top of the page. By collapsing the details, I get a nice summary of what’s passed and failed and I can then drill in to see just the errors I’m concerned about.

Before the change I can’t see more than a couple results without scrolling:mbunit-report-before.PNG

After I can collapse the the results and see them many at a glance:mbunit-report-after.PNG

Download the XSL file here.

  • Andre
    I would like to do something similar to that, but I don't want to have to change MbUnit's source. Is there any way to set the XML reports to use a custom stylesheet?

    I don't mind opening the XML file instead of generating an HTML one, as long as it uses my stylesheet (and I also don't have to change the file manually to use it).

    Do you know how I can achieve this?
  • Jeff
    Great work!
    I'm putting this into service pronto!
blog comments powered by Disqus