Created
April 1, 2015 15:17
-
-
Save ivanursul/15a96f98ddf4ecb01fd1 to your computer and use it in GitHub Desktop.
LoggingRule.java for www.ivanursul.com
This file contains hidden or 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
| package org.ivanursul.investigration.rule; | |
| import org.junit.rules.TestRule; | |
| import org.junit.runner.Description; | |
| import org.junit.runners.model.Statement; | |
| public class LoggingRule implements TestRule { | |
| private String name; | |
| public class LoggingStatement extends Statement { | |
| private final Statement statement; | |
| public LoggingStatement(final Statement statement) { | |
| this.statement = statement; | |
| } | |
| @Override | |
| public void evaluate() throws Throwable { | |
| System.out.println("before: " + name); | |
| statement.evaluate(); | |
| System.out.println("after: " + name); | |
| } | |
| } | |
| public LoggingRule(final String name) { | |
| super(); | |
| this.name = name; | |
| } | |
| @Override | |
| public Statement apply(final Statement base, final Description description) { | |
| return new LoggingStatement(base); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment