use of org.junit.jupiter.api.extension.ConditionEvaluationResult in project junit5 by junit-team.
the class ScriptExecutionConditionTests method enabledDueToAnnotationNotPresent.
@Test
void enabledDueToAnnotationNotPresent() {
ScriptExecutionCondition condition = new ScriptExecutionCondition();
ExtensionContext context = Mockito.mock(ExtensionContext.class);
Optional<AnnotatedElement> optionalElement = Optional.of(ScriptExecutionConditionTests.class);
Mockito.when(context.getElement()).thenReturn(optionalElement);
ConditionEvaluationResult result = condition.evaluateExecutionCondition(context);
assertFalse(result.isDisabled());
assertThat(result.getReason()).contains("Annotation not present");
}
use of org.junit.jupiter.api.extension.ConditionEvaluationResult in project junit5 by junit-team.
the class ScriptExecutionEvaluatorTests method computeConditionEvaluationResultWithDefaultReasonMessage.
@Test
void computeConditionEvaluationResultWithDefaultReasonMessage() {
Script script = script(EnabledIf.class, "?");
ConditionEvaluationResult result = evaluator.computeConditionEvaluationResult(script, "!");
assertTrue(result.isDisabled());
assertThat(result.getReason()).contains("Script `?` evaluated to: !");
}
use of org.junit.jupiter.api.extension.ConditionEvaluationResult in project junit5 by junit-team.
the class ConditionEvaluator method evaluate.
private ConditionEvaluationResult evaluate(ExecutionCondition condition, ExtensionContext context) {
try {
ConditionEvaluationResult result = condition.evaluateExecutionCondition(context);
logResult(condition.getClass(), result);
return result;
} catch (Exception ex) {
throw evaluationException(condition.getClass(), ex);
}
}
use of org.junit.jupiter.api.extension.ConditionEvaluationResult in project junit5 by junit-team.
the class ScriptExecutionConditionTests method enabledDueToAnnotatedElementNotPresent.
@Test
void enabledDueToAnnotatedElementNotPresent() {
ScriptExecutionCondition condition = new ScriptExecutionCondition();
ExtensionContext context = Mockito.mock(ExtensionContext.class);
ConditionEvaluationResult result = condition.evaluateExecutionCondition(context);
assertFalse(result.isDisabled());
assertThat(result.getReason()).contains("AnnotatedElement not present");
}
use of org.junit.jupiter.api.extension.ConditionEvaluationResult in project junit5 by junit-team.
the class ScriptExecutionEvaluatorTests method getJUnitConfigurationParameterWithJavaScriptAndCheckForNull.
@Test
void getJUnitConfigurationParameterWithJavaScriptAndCheckForNull() {
Script script = script(DisabledIf.class, "junitConfigurationParameter.get('XXX') == null");
ConditionEvaluationResult result = evaluate(script);
assertTrue(result.isDisabled());
//
assertThat(result.getReason()).contains("Script `junitConfigurationParameter.get('XXX') == null` evaluated to: true");
}
Aggregations