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

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

源代码1 项目: ignite   文件: RunningQueriesTest.java
/** {@inheritDoc} */
@Override protected void failed(Throwable e, Description lastTest) {
    try {
        log().error("Last test failed [name=" + lastTest.getMethodName() +
            ", reason=" + e.getMessage() + "]. Restarting the grid.");

        // Release the indexing.
        if (barrier != null)
            barrier.reset();

        stopAllGrids();

        beforeTestsStarted();

        log().error("Grid restarted.");
    }
    catch (Exception restartFailure) {
        throw new RuntimeException("Failed to recover after test failure [test=" + lastTest.getMethodName() +
            ", reason=" + e.getMessage() + "]. Subsequent test results of this test class are incorrect.",
            restartFailure);
    }
}
 
private void map(Description source, Description parent) {
    for (Description child : source.getChildren()) {
        Description mappedChild;
        if (child.getMethodName() != null) {
            mappedChild = Description.createSuiteDescription(String.format("%s [%s](%s)", child.getMethodName(), getDisplayName(), child.getClassName()));
            parent.addChild(mappedChild);
            if (!isTestEnabled(new TestDescriptionBackedTestDetails(source, child))) {
                disabledTests.add(child);
            } else {
                enabledTests.add(child);
            }
        } else {
            mappedChild = Description.createSuiteDescription(child.getClassName());
        }
        descriptionTranslations.put(child, mappedChild);
        map(child, parent);
    }
}
 
源代码3 项目: camunda-engine-dmn   文件: DmnEngineTestRule.java
protected String expandResourcePath(Description description, String resourcePath) {
  if (resourcePath.contains("/")) {
    // already expanded path
    return resourcePath;
  }
  else {
    Class<?> testClass = description.getTestClass();
    if (resourcePath.isEmpty()) {
      // use test class and method name as resource file name
      return testClass.getName().replace(".", "/") + "." + description.getMethodName() + "." + DMN_SUFFIX;
    }
    else {
      // use test class location as resource location
      return testClass.getPackage().getName().replace(".", "/") + "/" + resourcePath;
    }
  }
}
 
源代码4 项目: camunda-bpm-platform   文件: DmnEngineTestRule.java
protected String expandResourcePath(Description description, String resourcePath) {
  if (resourcePath.contains("/")) {
    // already expanded path
    return resourcePath;
  }
  else {
    Class<?> testClass = description.getTestClass();
    if (resourcePath.isEmpty()) {
      // use test class and method name as resource file name
      return testClass.getName().replace(".", "/") + "." + description.getMethodName() + "." + DMN_SUFFIX;
    }
    else {
      // use test class location as resource location
      return testClass.getPackage().getName().replace(".", "/") + "/" + resourcePath;
    }
  }
}
 
源代码5 项目: camunda-bpmn-model   文件: ParseBpmnModelRule.java
@Override
protected void starting(Description description) {

  if(description.getAnnotation(BpmnModelResource.class) != null) {

    Class<?> testClass = description.getTestClass();
    String methodName = description.getMethodName();

    String resourceFolderName = testClass.getName().replaceAll("\\.", "/");
    String bpmnResourceName = resourceFolderName + "." + methodName + ".bpmn";

    InputStream resourceAsStream = getClass().getClassLoader().getResourceAsStream(bpmnResourceName);
    try {
      bpmnModelInstance = Bpmn.readModelFromStream(resourceAsStream);
    } finally {
      IoUtil.closeSilently(resourceAsStream);
    }

  }

}
 
@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);
}
 
源代码7 项目: allure1   文件: AllureRunListener.java
public void startFakeTestCase(Description description) {
    String uid = getSuiteUid(description);

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

    fireClearStepStorage();
    getLifecycle().fire(event);
}
 
源代码8 项目: attic-apex-malhar   文件: DefaultBucketTest.java
@Override
protected void starting(Description description)
{
  //lots of test case get around the normal workflow and directly write to file. So should disable bloom filter
  DefaultBucket.setDisableBloomFilterByDefault(true);

  TestUtils.deleteTargetTestClassFolder(description);
  managedStateContext = new MockManagedStateContext(ManagedStateTestUtils.getOperatorContext(9));
  applicationPath = "target/" + description.getClassName() + "/" + description.getMethodName();
  ((FileAccessFSImpl)managedStateContext.getFileAccess()).setBasePath(applicationPath + "/" + "bucket_data");
  managedStateContext.getFileAccess().init();

  defaultBucket = new Bucket.DefaultBucket(1);
  managedStateContext.getBucketsFileSystem().setup(managedStateContext);
}
 
源代码9 项目: kurento-java   文件: KurentoTestListener.java
@Override
public void testStarted(Description description) {
  String methodName = description.getMethodName();
  KurentoTest.setTestMethodName(methodName);
  log.debug("Starting test {}.{}", testClass.getName(), methodName);

  invokeServices(ServiceMethod.START, TEST);

  KurentoTest
      .logMessage("|       TEST STARTING: " + description.getClassName() + "." + methodName);
}
 
源代码10 项目: JPPF   文件: ResultHolder.java
/**
 * Process the specified test description.
 * @param desc the test description.
 */
private void processDescription(final Description desc) {
  final String name = desc.getClassName();
  final String testName = name + "." + desc.getMethodName();
  if (!classes.contains(name)) classes.add(name);
  if (!tests.contains(testName)) tests.add(testName);
}
 
源代码11 项目: attic-apex-malhar   文件: FileSystemWALTest.java
@Override
protected void starting(Description description)
{
  targetDir = "target/" + description.getClassName() + "/" + description.getMethodName();

  try {
    fs = FileSystem.get(new URI(targetDir + "/WAL"), conf);
    fs.delete(new Path(targetDir), true);
  } catch (IOException | URISyntaxException e) {
    throw new RuntimeException(e);
  }

  fsWAL = new FileSystemWAL();
  fsWAL.setFilePath(targetDir + "/WAL");
}
 
源代码12 项目: bazel   文件: RegExTestCaseFilter.java
private static String formatDescriptionName(Description description) {
  String methodName = (description.getMethodName() == null) ? "" : description.getMethodName();

  String className = (description.getClassName() == null) ? "" : description.getClassName();
  if (methodName.trim().isEmpty() || className.trim().isEmpty()) {
    return description.getDisplayName();
  }
  return String.format(TEST_NAME_FORMAT, className, methodName);
}
 
源代码13 项目: usergrid   文件: ClientSetup.java
protected void before(Description description) throws IOException {
    String testClass = description.getTestClass().getName();
    String methodName = description.getMethodName();
    String name = testClass + "." + methodName;

    try {
        restClient.superuserSetup();
        superuserToken = restClient.management().token().get(superuserName, superuserPassword);
    } catch (BadRequestException e) {
        logger.warn("Error creating superuser, may already exist");
    }


    username = "user_" + name + UUIDUtils.newTimeUUID();
    password = username;
    orgName = "org_" + name + UUIDUtils.newTimeUUID();
    appName = "app_" + name + UUIDUtils.newTimeUUID();

    organization = restClient.management().orgs().post(
        new Organization(orgName, username, username + "@usergrid.com", username, password, null));

    restClient.management().token().get(username, password);

    clientCredentials = restClient.management().orgs().org(orgName).credentials().get(Credentials.class);
    //appCredentials = restClient.management().orgs().org(orgName).app().path//.credentials().get(Credentials.class);


    ApiResponse appResponse = restClient.management().orgs()
        .org(organization.getName()).app().post(new Application(appName));
    appUuid = (String) appResponse.getEntities().get(0).get("uuid");
    application = new Application(appResponse);

    appCredentials = restClient.pathResource( "management/orgs/"+orgName+"/apps/"+appName+"/credentials" ).get( Credentials.class,true );

    refreshIndex();

    ApiResponse response = restClient.management().token().post(new Token(username, password));
    refreshIndex();
}
 
源代码14 项目: 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();
        }
    };
}
 
源代码15 项目: ogham   文件: LoggingTestRule.java
private static String getTestName(Description description) {
	return description.getTestClass().getSimpleName() + SEPARATOR + description.getMethodName();
}
 
源代码16 项目: helios   文件: TemporaryJobJsonReports.java
public ReportWriter getWriterForTest(final Description testDescription) {
  return new JsonReportWriter(
      outputDir, testDescription.getClassName(), testDescription.getMethodName());
}
 
源代码17 项目: nopol   文件: DynamothSynthesizer.java
@Override
public void testFailure(Failure failure) throws Exception {
    Description description = failure.getDescription();
    String key = description.getClassName() + "#" + description.getMethodName();
    failedTests.put(key, AngelicExecution.previousValue);
}
 
源代码18 项目: dekaf   文件: TeamCityListener.java
private String getTestName(Description d) {
  return d.getClassName() + "." + d.getMethodName();
}
 
源代码19 项目: dsl-devkit   文件: LoggingRule.java
/**
 * Returns the name of a test to be logged.
 * 
 * @param description
 *          the description, must not be {@code null}
 * @return the description name, never {@code null}
 */
private String getDescriptionName(final Description description) {
  return description.getClassName() + '.' + description.getMethodName();
}
 
源代码20 项目: dsl-devkit   文件: FilterRegistry.java
/**
 * Determines if the given {@link Description} is describing a test method.
 *
 * @param description
 *          the {@link Description} to check, must not be {@code null}
 * @return whether the description is describing a test method
 */
public static boolean isTestMethod(final Description description) {
  return description.getMethodName() != null;
}