-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #869 from michalvavrik/feature/quarkus-tests-needs…
…-a-way-to-disable-on-docker Provide a way to disable QuarkusTests without Docker
- Loading branch information
Showing
3 changed files
with
56 additions
and
5 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
.../main/java/io/quarkus/test/scenarios/annotations/EnabledWhenLinuxContainersAvailable.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.quarkus.test.scenarios.annotations; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import org.junit.jupiter.api.extension.ExtendWith; | ||
|
||
/** | ||
* Provides option to explicitly enable test only when Linux containers are available. | ||
* The framework automatically detects when Linux containers are needed and only run tests | ||
* when environment supports them. However, you may need to annotate tests with this annotation | ||
* when our framework is not used (like when the QuarkusTest annotation is used). | ||
*/ | ||
@Inherited | ||
@Target({ ElementType.TYPE, ElementType.METHOD }) | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@ExtendWith(EnabledWhenLinuxContainersAvailableCondition.class) | ||
public @interface EnabledWhenLinuxContainersAvailable { | ||
/** | ||
* Why is the annotated test class or test method disabled. | ||
*/ | ||
String reason() default ""; | ||
} |
25 changes: 25 additions & 0 deletions
25
...a/io/quarkus/test/scenarios/annotations/EnabledWhenLinuxContainersAvailableCondition.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.quarkus.test.scenarios.annotations; | ||
|
||
import static io.quarkus.test.scenarios.execution.condition.AbstractQuarkusScenarioContainerExecutionCondition.ENV_DOES_NOT_SUPPORT_LINUX_CONTAINERS; | ||
import static io.quarkus.test.scenarios.execution.condition.AbstractQuarkusScenarioContainerExecutionCondition.ENV_SUPPORTS_LINUX_CONTAINERS; | ||
import static java.lang.String.format; | ||
import static org.junit.jupiter.api.extension.ConditionEvaluationResult.disabled; | ||
|
||
import org.junit.jupiter.api.extension.ConditionEvaluationResult; | ||
import org.junit.jupiter.api.extension.ExecutionCondition; | ||
import org.junit.jupiter.api.extension.ExtensionContext; | ||
|
||
import io.quarkus.test.scenarios.execution.condition.AbstractQuarkusScenarioContainerExecutionCondition; | ||
|
||
public class EnabledWhenLinuxContainersAvailableCondition implements ExecutionCondition { | ||
|
||
@Override | ||
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext extensionContext) { | ||
if (AbstractQuarkusScenarioContainerExecutionCondition.areLinuxContainersSupported()) { | ||
return ENV_SUPPORTS_LINUX_CONTAINERS; | ||
} else { | ||
String testName = extensionContext.getDisplayName(); | ||
return disabled(format(ENV_DOES_NOT_SUPPORT_LINUX_CONTAINERS, testName)); | ||
} | ||
} | ||
} |
This file contains 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