当前位置: 首页>>代码示例>>Java>>正文


Java ConditionEvaluationResult.disabled方法代码示例

本文整理汇总了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;
}
 
开发者ID:bonigarcia,项目名称:mastering-junit5,代码行数:26,代码来源:OsCondition.java

示例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;
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:22,代码来源:CIServerCondition.java

示例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);
}
 
开发者ID:sormuras,项目名称:bach,代码行数:16,代码来源:DisabledCondition.java

示例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 + ".");
}
 
开发者ID:CodeFX-org,项目名称:demo-junit-5,代码行数:8,代码来源:OsCondition.java

示例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));
	}
}
 
开发者ID:junit-pioneer,项目名称:junit-pioneer,代码行数:10,代码来源:OsCondition.java

示例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


注:本文中的org.junit.jupiter.api.extension.ConditionEvaluationResult.disabled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。