Home » Core Java » junit (page 7)

junit

JUnit Rules Example

The implementation of a Rule might look like this: import org.junit.rules.TestRule; import org.junit.runner.Description; import org.junit.runners.model.Statement; public class LoggingRule implements TestRule { public class LoggingStatement extends Statement { private final Statement statement; public LoggingStatement(Statement aStatement, String aName) { statement = aStatement; } @Override public void evaluate() throws Throwable { System.out.println("before: " + name); statement.evaluate(); System.out.println("after: " + name); } } private ...

Read More »