Created
October 17, 2017 18:55
-
-
Save thombergs/263bacc8f605d41788962e6e5f82f9e8 to your computer and use it in GitHub Desktop.
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
public class AssumingConnection implements TestRule { | |
private ConnectionChecker checker; | |
public AssumingConnection(ConnectionChecker checker) { | |
this.checker = checker; | |
} | |
@Override | |
public Statement apply(Statement base, Description description) { | |
return new Statement() { | |
@Override | |
public void evaluate() throws Throwable { | |
if (!checker.connect()) { | |
throw new AssumptionViolatedException("Skipping Test!"); | |
} else { | |
base.evaluate(); | |
} | |
} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment