getDisplayName()源码实例Demo

org.junit.jupiter.api.extension.ExtensionContext#getDisplayName()源码实例Demo

下面列出了org.junit.jupiter.api.extension.ExtensionContext#getDisplayName() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: exonum-java-binding   文件: TestKitExtension.java
@Override
public Object resolveParameter(
    ParameterContext parameterContext, ExtensionContext extensionContext)
    throws ParameterResolutionException {
  checkExtensionContext(extensionContext);
  CloseableTestKit closeableTestKit =
      getStore(extensionContext).get(TESTKIT_KEY, CloseableTestKit.class);
  TestKit testKit;
  if (closeableTestKit == null) {
    testKit = buildTestKit(parameterContext, extensionContext);
    getStore(extensionContext).put(TESTKIT_KEY, new CloseableTestKit(testKit));
  } else {
    // Throw an exception if TestKit was already instantiated in this context, but user tries to
    // reconfigure it
    if (annotationsUsed(parameterContext)) {
      throw new ParameterResolutionException("TestKit was parameterized with annotations after"
          + " being instantiated in " + extensionContext.getDisplayName());
    }
    testKit = closeableTestKit.getTestKit();
  }
  return testKit;
}
 
源代码2 项目: exonum-java-binding   文件: TestKitExtension.java
private TestKit.Builder createTestKitBuilder(ParameterContext parameterContext,
    ExtensionContext extensionContext) {
  TestKit.Builder testKitBuilder = templateTestKitBuilder.shallowCopy();
  Optional<Auditor> auditorAnnotation = parameterContext.findAnnotation(Auditor.class);
  Optional<Validator> validatorAnnotation = parameterContext.findAnnotation(Validator.class);
  if (auditorAnnotation.isPresent() && validatorAnnotation.isPresent()) {
    throw new ParameterResolutionException("Both @Validator and @Auditor annotations were used"
        + " in " + extensionContext.getDisplayName());
  }
  auditorAnnotation.ifPresent(auditor -> testKitBuilder.withNodeType(EmulatedNodeType.AUDITOR));
  validatorAnnotation.ifPresent(validator ->
      testKitBuilder.withNodeType(EmulatedNodeType.VALIDATOR));

  Optional<ValidatorCount> validatorCountAnnotation =
      parameterContext.findAnnotation(ValidatorCount.class);
  validatorCountAnnotation.ifPresent(validatorCount ->
      testKitBuilder.withValidators(validatorCount.value()));
  return testKitBuilder;
}
 
源代码3 项目: enmasse   文件: TestUtils.java
public static Path getLogsPath(ExtensionContext extensionContext, String rootFolder) {
    String testMethod = extensionContext.getDisplayName();
    Class<?> testClass = extensionContext.getRequiredTestClass();
    Path path = Environment.getInstance().testLogDir().resolve(Paths.get(rootFolder, testClass.getName()));
    if (testMethod != null) {
        path = path.resolve(testMethod);
    }
    return path;
}