Skip to content

Instantly share code, notes, and snippets.

@thombergs
Created October 17, 2017 18:55
Show Gist options
  • Save thombergs/263bacc8f605d41788962e6e5f82f9e8 to your computer and use it in GitHub Desktop.
Save thombergs/263bacc8f605d41788962e6e5f82f9e8 to your computer and use it in GitHub Desktop.
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