Created
May 15, 2012 19:24
-
-
Save xhawk/2704384 to your computer and use it in GitHub Desktop.
ScreenshotRule
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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