Skip to content

Instantly share code, notes, and snippets.

@kranthilakum
Created December 23, 2012 13:13
Show Gist options
  • Save kranthilakum/4363347 to your computer and use it in GitHub Desktop.
Save kranthilakum/4363347 to your computer and use it in GitHub Desktop.
An implementation of a Rule overriding TestWatcher methods. A class only to be used for logging test cases activities.
/**
* An implementation of a {@link Rule} overriding {@link TestWatcher} methods.
* A class only to be used for logging test cases activities.
*
* @author Kranthi Lakum
*
*/
public class TestWatch extends TestWatcher
{
// SLF4J Logger instance for this class.
private static Logger myLogger = LoggerFactory.getLogger(TestWatch.class.getName());
@Override
protected void failed(Throwable e, Description description)
{
myLogger.info("Testcase has failed: [{}] \n{}.", description.getMethodName(), e);
}
@Override
protected void succeeded(Description description)
{
myLogger.info("Testcase has passed: [{}].", description.getMethodName());
}
@Override
protected void starting(Description description)
{
myLogger.info("Running testcase: [{}].", description.getMethodName());
}
@Override
protected void finished(Description description)
{
myLogger.info("Testing: [{}] has finished.", description.getMethodName());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment