Skip to content

Instantly share code, notes, and snippets.

@xhawk
Created May 15, 2012 19:24
Show Gist options
  • Save xhawk/2704384 to your computer and use it in GitHub Desktop.
Save xhawk/2704384 to your computer and use it in GitHub Desktop.
ScreenshotRule
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
public class ScreenshotRule implements TestRule {
public Statement apply(final Statement statement, final Description description) {
return new Statement() {
@Override
public void evaluate() throws Throwable {
try {
statement.evaluate();
} catch (Exception e){
System.out.println("Took screenshot!");
throw e;
}
}
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment