Here's a cross platform way to take a screen shot if a junit test fails.
Note that if you're using WebDriver then some of the browser implementations can do this anyway.., take a look at Taking A Screenshot When A WebDriver Test Fails
You could also do this with a JUnit Rule, see Taking A Screenshot When A JUnit Test Fails Using A Rule, if you're using JUnit 4
Labels: