本文整理汇总了Java中org.junit.jupiter.api.extension.ConditionEvaluationResult.disabled方法的典型用法代码示例。如果您正苦于以下问题:Java ConditionEvaluationResult.disabled方法的具体用法?Java ConditionEvaluationResult.disabled怎么用?Java ConditionEvaluationResult.disabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.junit.jupiter.api.extension.ConditionEvaluationResult
的用法示例。
在下文中一共展示了ConditionEvaluationResult.disabled方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: evaluateExecutionCondition
import org.junit.jupiter.api.extension.ConditionEvaluationResult; //导入方法依赖的package包/类
@Override
public ConditionEvaluationResult evaluateExecutionCondition(
ExtensionContext context) {
Optional<AnnotatedElement> element = context.getElement();
ConditionEvaluationResult out = ConditionEvaluationResult
.enabled("@DisabledOnOs is not present");
Optional<DisabledOnOs> disabledOnOs = AnnotationUtils
.findAnnotation(element, DisabledOnOs.class);
if (disabledOnOs.isPresent()) {
Os myOs = Os.determine();
if (Arrays.asList(disabledOnOs.get().value()).contains(myOs)) {
out = ConditionEvaluationResult
.disabled("Test is disabled on " + myOs);
} else {
out = ConditionEvaluationResult
.enabled("Test is not disabled on " + myOs);
}
}
System.out.println("--> " + out.getReason().get());
return out;
}
示例2: evaluateExecutionCondition
import org.junit.jupiter.api.extension.ConditionEvaluationResult; //导入方法依赖的package包/类
@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
// Search for the @DisabledWeekdays annotation from the TestExtensionContext
Optional<AnnotatedElement> contextElement = context.getElement();
AnnotatedElement annotatedElement = contextElement.orElse(null);
if (annotatedElement == null) return null;
DisabledWeekdays weekdayAnnotation = annotatedElement.getAnnotation(DisabledWeekdays.class);
// Determine whether the test should be disabled
boolean weekdayToday = IntStream.of(weekdayAnnotation.value())
.anyMatch(day -> day == Calendar.getInstance().get(Calendar.DAY_OF_WEEK));
// Return a ConditionEvaluationResult based on the outcome of the boolean weekdayToday
return weekdayToday ?
ConditionEvaluationResult.disabled("I spare you today.") :
ConditionEvaluationResult.enabled("Don't spare you on other days though >:(");
}
开发者ID:msg-DAVID-GmbH,项目名称:JUnit-5-Quick-Start-Guide-with-AssertJ-Spring-TestFX-Mockito,代码行数:21,代码来源:DisabledOnWeekday.java
示例3: evaluateExecutionCondition
import org.junit.jupiter.api.extension.ConditionEvaluationResult; //导入方法依赖的package包/类
/**
* Containers and tests are disabled if they are annotated with {@link DisabledOnCIServer} and they tests are run on
* the CI server.
*/
@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
if (!isCIServer()) {
return ENABLED;
}
Optional<AnnotatedElement> element = context.getElement();
Optional<DisabledOnCIServer> disabled = AnnotationUtils.findAnnotation(element, DisabledOnCIServer.class);
if (disabled.isPresent()) {
String reason = disabled.map(DisabledOnCIServer::value)
.filter(StringUtil::isNotBlank)
.orElseGet(() -> element.get() + " is disabled on CI server");
return ConditionEvaluationResult.disabled(reason);
}
return ENABLED;
}
示例4: evaluateExecutionCondition
import org.junit.jupiter.api.extension.ConditionEvaluationResult; //导入方法依赖的package包/类
@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext extensionContext) {
AnnotatedElement element = extensionContext.getElement().orElseThrow(AssertionError::new);
Disabled disabled = findAnnotation(element, Disabled.class).orElseThrow(AssertionError::new);
String name = disabled.value();
String reason = name + "=" + System.getProperty(name);
boolean result = Boolean.getBoolean(name);
if (disabled.not()) {
result = !result;
}
if (result) {
return ConditionEvaluationResult.disabled(reason);
}
return ConditionEvaluationResult.enabled(reason);
}
示例5: disabledIfOn
import org.junit.jupiter.api.extension.ConditionEvaluationResult; //导入方法依赖的package包/类
private ConditionEvaluationResult disabledIfOn(OS[] disabledOnOs) {
OS os = OS.determine();
if (Arrays.asList(disabledOnOs).contains(os))
return ConditionEvaluationResult.disabled("Test is disabled on " + os + ".");
else
return ConditionEvaluationResult.enabled("Test is not disabled in " + os + ".");
}
示例6: disabledIfOn
import org.junit.jupiter.api.extension.ConditionEvaluationResult; //导入方法依赖的package包/类
private ConditionEvaluationResult disabledIfOn(OS[] disabledOnOs) {
OS os = osDetector.get();
if (Arrays.asList(disabledOnOs).contains(os)) {
return ConditionEvaluationResult.disabled(format(TEST_DISABLED, os));
}
else {
return ConditionEvaluationResult.enabled(format(TEST_ENABLED, os));
}
}
示例7: evaluateExecutionCondition
import org.junit.jupiter.api.extension.ConditionEvaluationResult; //导入方法依赖的package包/类
@Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
boolean monday = Calendar.getInstance().get(Calendar.DAY_OF_WEEK) == Calendar.MONDAY;
return monday ?
ConditionEvaluationResult.disabled("I spare you on Mondays.") :
ConditionEvaluationResult.enabled("Don't spare you on other days though >:(");
}
开发者ID:msg-DAVID-GmbH,项目名称:JUnit-5-Quick-Start-Guide-with-AssertJ-Spring-TestFX-Mockito,代码行数:9,代码来源:DisabledOnMonday.java