Skip to content

Commit

Permalink
Skipping tests properly if "gl2.integration.tests" property is not set.
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisoelkers committed Jun 25, 2015
1 parent 93eeadb commit 9d7a180
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 18 deletions.
Expand Up @@ -20,6 +20,7 @@
import org.junit.Rule;

public class BaseRestTest extends BaseRestTestHelper {
@ClassRule public static RunIfProperty runIfProperty = new RunIfProperty("gl2.integration.tests");
@ClassRule public static RestAssuredSetupRule restAssuredSetupRule = new RestAssuredSetupRule();
@Rule public RequiredVersionRule requiredVersionRule = new RequiredVersionRule(restAssuredSetupRule);
@Rule public MongoDbSeedRule mongoDbSeedRule = new MongoDbSeedRule();
Expand Down
17 changes: 17 additions & 0 deletions integration-tests/src/test/java/integration/IgnoreStatement.java
@@ -0,0 +1,17 @@
package integration;

import org.junit.Assume;
import org.junit.runners.model.Statement;

class IgnoreStatement extends Statement {
private final String message;

public IgnoreStatement(String message) {
this.message = message;
}

@Override
public void evaluate() throws Throwable {
Assume.assumeTrue(this.message, false);
}
}
Expand Up @@ -62,17 +62,4 @@ public Statement apply(Statement base, FrameworkMethod method, Object target) {
return base;
}
}

class IgnoreStatement extends Statement {
private final String message;

public IgnoreStatement(String message) {
this.message = message;
}

@Override
public void evaluate() throws Throwable {
Assume.assumeTrue(this.message, false);
}
}
}
Expand Up @@ -36,11 +36,6 @@ public class RestAssuredSetupRule extends ExternalResource {

@Override
protected void before() throws Throwable {
if (System.getProperty("gl2.integration.tests") == null) {
// TODO: properly skip execution
throw new RuntimeException("Not running REST API integration tests. Add -Dgl2.integration.tests to run them.");
}

final GraylogControl graylogController = new GraylogControl();
final URL url = graylogController.getUrl();
RestAssured.baseURI = url.getProtocol() + "://" + url.getHost();
Expand Down
23 changes: 23 additions & 0 deletions integration-tests/src/test/java/integration/RunIfProperty.java
@@ -0,0 +1,23 @@
package integration;

import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;

public class RunIfProperty implements TestRule {
private final String propertyName;

public RunIfProperty(String propertyName) {
this.propertyName = propertyName;
}

@Override
public Statement apply(Statement base, Description description) {
final String propertyValue = System.getProperty(this.propertyName);
if (propertyValue == null || !Boolean.valueOf(propertyValue)) {
return new IgnoreStatement("Not running REST API integration tests. Add -Dgl2.integration.tests to run them.");
} else {
return base;
}
}
}

0 comments on commit 9d7a180

Please sign in to comment.