• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JUnit fail action

 
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there

I'm busy writing tests with JUnit and I want to know if there is a way to perform a specific action every time any test fails.

For example, show the xml log output in a browser or something. At the moment, when it fails I have to manually find the log file I'm generating and open it and after the hundredth time today it would be really awesome if it could open the file on it's own.

Any suggestions would be greatly appreciated!
Many thanks,
Rachel
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do you run the tests? What do you need the log file for? Don't you use a gui testrunner?
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Since you're talking about XML log output, I assume you're using the <junit/> Ant task? If that's the case, how about also using the <junitreport/> task for generating a pretty HTML report for your test run?

Also, you could do some Ant trickery to launch the report in a web browser when some tests fail:
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there

The logs files aren't the direct output of the test run. The test script is testing code that generates xml logs based on given criteria.

The ant idea works well, so that's gone in. Thanks for the advice!

Rachel
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you need to take a look at them regularly? That seems to be counter to the whole purpose of automated unit tests to me...
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic