Search in sources :

Example 1 with DisabledIf

use of org.junit.jupiter.api.condition.DisabledIf in project junit5 by junit-team.

the class ScriptExecutionCondition method createDisabledIfScriptOrNull.

private Script createDisabledIfScriptOrNull(AnnotatedElement annotatedElement) {
    Optional<DisabledIf> disabled = findAnnotation(annotatedElement, DisabledIf.class);
    if (!disabled.isPresent()) {
        return null;
    }
    DisabledIf annotation = disabled.get();
    String source = createSource(annotation.value());
    return new Script(annotation, annotation.engine(), source, annotation.reason());
}
Also used : Script(org.junit.jupiter.engine.script.Script) DisabledIf(org.junit.jupiter.api.condition.DisabledIf)

Example 2 with DisabledIf

use of org.junit.jupiter.api.condition.DisabledIf in project junit5 by junit-team.

the class ScriptExecutionConditionTests method annotationDefaultValues.

@Test
@EnabledIf("true")
@DisabledIf("false")
void annotationDefaultValues(TestInfo info) {
    EnabledIf e = info.getTestMethod().orElseThrow(Error::new).getDeclaredAnnotation(EnabledIf.class);
    assertEquals("Nashorn", e.engine());
    assertEquals("Script `{source}` evaluated to: {result}", e.reason());
    DisabledIf d = info.getTestMethod().orElseThrow(Error::new).getDeclaredAnnotation(DisabledIf.class);
    assertEquals("Nashorn", d.engine());
    assertEquals("Script `{source}` evaluated to: {result}", d.reason());
}
Also used : EnabledIf(org.junit.jupiter.api.condition.EnabledIf) DisabledIf(org.junit.jupiter.api.condition.DisabledIf) Test(org.junit.jupiter.api.Test) EnabledIf(org.junit.jupiter.api.condition.EnabledIf) DisabledIf(org.junit.jupiter.api.condition.DisabledIf)

Aggregations

DisabledIf (org.junit.jupiter.api.condition.DisabledIf)2 Test (org.junit.jupiter.api.Test)1 EnabledIf (org.junit.jupiter.api.condition.EnabledIf)1 Script (org.junit.jupiter.engine.script.Script)1