org.junit.runner.Description#getClassName()源码实例Demo

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

源代码1 项目: activiti6-boot2   文件: ActivitiRule.java
protected void finished(Description description) {

		// Remove the test deployment
		try {
			TestHelper.annotationDeploymentTearDown(processEngine, deploymentId,
			    Class.forName(description.getClassName()), description.getMethodName());
		} catch (ClassNotFoundException e) {
			throw new ActivitiException("Programmatic error: could not instantiate "
			    + description.getClassName(), e);
		}

		// Reset internal clock
		processEngineConfiguration.getClock().reset();

		// Rest mocks
		if (mockSupport != null) {
			TestHelper.annotationMockSupportTeardown(mockSupport);
		}
	}
 
源代码2 项目: attic-apex-core   文件: AsyncFSStorageAgentTest.java
@Override
protected void starting(Description description)
{
  super.starting(description);
  basePath = "target/" + description.getClassName() + "/" + description.getMethodName();
  applicationPath = basePath + "/app";
  try {
    FileUtils.forceMkdir(new File(basePath));
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
  storageAgent = new AsyncFSStorageAgent(applicationPath, null);

  Attribute.AttributeMap.DefaultAttributeMap attributes = new Attribute.AttributeMap.DefaultAttributeMap();
  attributes.put(DAG.APPLICATION_PATH, applicationPath);
}
 
源代码3 项目: android-test   文件: TestRequestBuilder.java
@Override
public boolean evaluateTest(Description description) {
  if (methodFilters.isEmpty()) {
    return true;
  }
  String className = description.getClassName();
  MethodFilter methodFilter = methodFilters.get(className);
  if (methodFilter != null) {
    return methodFilter.shouldRun(description);
  }
  // This test class was not explicitly excluded and none of it's test methods were
  // explicitly included or excluded. Should be run, return true:
  return true;
}
 
@Override
protected void failed(final Throwable e, final Description description) {
    final String methodName = description.getMethodName();
    String className = description.getClassName();
    className = className.substring(className.lastIndexOf('.') + 1);
    System.out.println(">>>> " + className + " " + methodName + " FAILED due to " + e);
}
 
@Override
protected void starting(final Description description) {
  String methodName = description.getMethodName();
  String className = description.getClassName();
  className = className.substring(className.lastIndexOf('.') + 1);
  // System.out.println("Starting JUnit-test: " + className + " " + methodName);
}
 
@Override
@SuppressWarnings("unchecked")
protected void starting(Description description) {
  String className = description.getClassName();
  className =  className.replaceAll("Test", "");
  Class<? extends ModelElementInstance> instanceClass = null;
  try {
    instanceClass = (Class<? extends ModelElementInstance>) Class.forName(className);
  } catch (ClassNotFoundException e) {
    throw new RuntimeException(e);
  }
  modelInstance = Bpmn.createEmptyModel();
  model = modelInstance.getModel();
  modelElementType = model.getType(instanceClass);
}
 
源代码7 项目: flowable-engine   文件: FlowableDmnRule.java
protected void finished(Description description) {

        // Remove the test deployment
        try {
            DmnTestHelper.annotationDeploymentTearDown(dmnEngine, deploymentId, Class.forName(description.getClassName()), description.getMethodName());
        } catch (ClassNotFoundException e) {
            throw new FlowableException("Programmatic error: could not instantiate " + description.getClassName(), e);
        }
    }
 
源代码8 项目: allure-cucumberjvm   文件: AllureRunListener.java
public void startFakeTestCase(Description description) throws IllegalAccessException {
    String uid = getSuiteUid(description);

    String name = description.isTest() ? description.getMethodName() : description.getClassName();
    TestCaseStartedEvent event = new TestCaseStartedEvent(uid, name);
    event.setTitle(name);
    AnnotationManager am = new AnnotationManager(description.getAnnotations());
    am.update(event);

    getLifecycle().fire(event);
}
 
源代码9 项目: flowable-engine   文件: FlowableFormRule.java
protected void finished(Description description) {

        // Remove the test deployment
        try {
            FormTestHelper.annotationDeploymentTearDown(formEngine, deploymentId, Class.forName(description.getClassName()), description.getMethodName());
        } catch (ClassNotFoundException e) {
            throw new FlowableException("Programmatic error: could not instantiate " + description.getClassName(), e);
        }
    }
 
@Override
@SuppressWarnings("unchecked")
protected void starting(Description description) {
  String className = description.getClassName();
  className =  className.replaceAll("Test", "");
  Class<? extends ModelElementInstance> instanceClass = null;
  try {
    instanceClass = (Class<? extends ModelElementInstance>) Class.forName(className);
  } catch (ClassNotFoundException e) {
    throw new RuntimeException(e);
  }
  modelInstance = Bpmn.createEmptyModel();
  model = modelInstance.getModel();
  modelElementType = model.getType(instanceClass);
}
 
源代码11 项目: testcontainers-java   文件: GenericContainer.java
private TestDescription toDescription(Description description) {
    return new TestDescription() {
        @Override
        public String getTestId() {
            return description.getDisplayName();
        }

        @Override
        public String getFilesystemFriendlyName() {
            return description.getClassName() + "-" + description.getMethodName();
        }
    };
}
 
源代码12 项目: allure-java   文件: AllureJunit4.java
private TestResult createTestResult(final String uuid, final Description description) {
    final String className = description.getClassName();
    final String methodName = description.getMethodName();
    final String name = Objects.nonNull(methodName) ? methodName : className;
    final String fullName = Objects.nonNull(methodName) ? String.format("%s.%s", className, methodName) : className;
    final String suite = Optional.ofNullable(description.getTestClass())
            .map(it -> it.getAnnotation(DisplayName.class))
            .map(DisplayName::value).orElse(className);

    final TestResult testResult = new TestResult()
            .setUuid(uuid)
            .setHistoryId(getHistoryId(description))
            .setFullName(fullName)
            .setName(name);

    testResult.getLabels().addAll(getProvidedLabels());
    testResult.getLabels().addAll(Arrays.asList(
            createPackageLabel(getPackage(description.getTestClass())),
            createTestClassLabel(className),
            createTestMethodLabel(name),
            createSuiteLabel(suite),
            createHostLabel(),
            createThreadLabel(),
            createFrameworkLabel("junit4"),
            createLanguageLabel("java")
    ));
    testResult.getLabels().addAll(extractLabels(description));
    testResult.getLinks().addAll(extractLinks(description));

    getDisplayName(description).ifPresent(testResult::setName);
    getDescription(description).ifPresent(testResult::setDescription);
    return testResult;
}
 
源代码13 项目: logging-log4j2   文件: LoggerContextRule.java
@Override
public Statement apply(final Statement base, final Description description) {
    // Hack: Using -DEBUG as a JVM param sets a property called "EBUG"...
    if (System.getProperties().containsKey("EBUG")) {
        StatusLogger.getLogger().setLevel(Level.DEBUG);
    }
    testClassName = description.getClassName();
    return new Statement() {
        @Override
        public void evaluate() throws Throwable {
            if (contextSelectorClass != null) {
                System.setProperty(Constants.LOG4J_CONTEXT_SELECTOR, contextSelectorClass.getName());
            }
            // TODO Consider instead of the above:
            // LogManager.setFactory(new Log4jContextFactory(LoaderUtil.newInstanceOf(contextSelectorClass)));
            System.setProperty(SYS_PROP_KEY_CLASS_NAME, description.getClassName());
            System.setProperty(SYS_PROP_KEY_DISPLAY_NAME, description.getDisplayName());
            loggerContext = Configurator.initialize(description.getDisplayName(),
                    description.getTestClass().getClassLoader(), configurationLocation);
            try {
                base.evaluate();
            } finally {
                if (!Configurator.shutdown(loggerContext, shutdownTimeout, shutdownTimeUnit)) {
                    StatusLogger.getLogger().error("Logger context {} did not shutdown completely after {} {}.",
                            loggerContext.getName(), shutdownTimeout, shutdownTimeUnit);
                }
                loggerContext = null;
                contextSelectorClass = null;
                StatusLogger.getLogger().reset();
                System.clearProperty(Constants.LOG4J_CONTEXT_SELECTOR);
                System.clearProperty(SYS_PROP_KEY_CLASS_NAME);
                System.clearProperty(SYS_PROP_KEY_DISPLAY_NAME);
            }
        }
    };

}
 
源代码14 项目: attic-apex-malhar   文件: StateTrackerTest.java
@Override
protected void starting(Description description)
{
  TestUtils.deleteTargetTestClassFolder(description);
  managedState = new MockManagedStateImpl();
  applicationPath = "target/" + description.getClassName() + "/" + description.getMethodName();
  ((FileAccessFSImpl)managedState.getFileAccess()).setBasePath(applicationPath + "/" + "bucket_data");

  managedState.setNumBuckets(2);
  managedState.setMaxMemorySize(100);

  operatorContext = ManagedStateTestUtils.getOperatorContext(1, applicationPath);
}
 
@Override
protected void starting(Description description)
{
  final String methodName = description.getMethodName();
  final String className = description.getClassName();

  testBase = new SQSTestBase();
  if (testBase.validateTestCreds() == false) {
    return;
  }
  testBase.generateCurrentQueueName(methodName);
  try {
    testBase.beforTest();
  } catch (AssumptionViolatedException ave) {
    throw ave;
  } catch (Exception e) {
    throw new RuntimeException(e);
  }

  baseDir = "target/" + className + "/" + methodName;

  Attribute.AttributeMap attributeMap = new Attribute.AttributeMap.DefaultAttributeMap();
  attributeMap.put(Context.OperatorContext.SPIN_MILLIS, 500);
  attributeMap.put(Context.DAGContext.APPLICATION_PATH, baseDir);

  context = mockOperatorContext(1, attributeMap);
  operator = new JMSStringInputOperator();
  operator.setConnectionFactoryBuilder(new JMSBase.ConnectionFactoryBuilder()
  {

    @Override
    public ConnectionFactory buildConnectionFactory()
    {
      // Create the connection factory using the environment variable credential provider.
      // Connections this factory creates can talk to the queues in us-east-1 region.
      SQSConnectionFactory connectionFactory =
          SQSConnectionFactory.builder()
          .withRegion(Region.getRegion(Regions.US_EAST_1))
          .withAWSCredentialsProvider(new PropertiesFileCredentialsProvider(testBase.getDevCredsFilePath()))
          .build();
      return connectionFactory;
    }

    @Override
    public String toString()
    {
      return className + "/" + methodName + "/ConnectionFactoryBuilder";
    }

  });
  operator.setSubject(testBase.getCurrentQueueName());
  // for SQS ack mode should be "AUTO_ACKNOWLEDGE" and transacted = false
  operator.setAckMode("AUTO_ACKNOWLEDGE");
  operator.setTransacted(false);

  sink = new CollectorTestSink<>();
  operator.output.setSink(sink);
  operator.setup(context);
  operator.activate(context);
}
 
源代码16 项目: rtg-tools   文件: RtgTestEntry.java
static String testName(Description description) {
  return description.getClassName() + "." + description.getMethodName();
}
 
源代码17 项目: dremio-oss   文件: BaseTestServer.java
private String desc(Description description) {
  return description.getClassName() + "." +  description.getMethodName();
}
 
源代码18 项目: helios   文件: TemporaryJobJsonReports.java
public ReportWriter getWriterForTest(final Description testDescription) {
  return new JsonReportWriter(
      outputDir, testDescription.getClassName(), testDescription.getMethodName());
}
 
源代码19 项目: dremio-oss   文件: DremioTest.java
@Override
protected void starting(Description description) {
  super.starting(description);
  className = description.getClassName();
  memWatcher = new MemWatcher();
}
 
源代码20 项目: JPPF   文件: ResultHolder.java
/**
 * Determine whether this result holder already has the specified test.
 * @param desc the description of th etest to look for.
 * @return <code>true</code> if the test already exists, <code>false</code> otherwise.
 */
public boolean hasTest(final Description desc) {
  final String name = desc.getClassName() + "." + desc.getMethodName();
  return tests.contains(name);
}