Java Code Examples for org.junit.runner.Description#getDisplayName()
The following examples show how to use
org.junit.runner.Description#getDisplayName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: N4IDEXpectFileNameUtil.java From n4js with Eclipse Public License 1.0 | 6 votes |
/***/ public static String getTestName(Description description) { String text = null; if (description.isTest()) { String s = description.getDisplayName(); if (s.startsWith(TEST_FILE_INIT_ERROR_MSG)) { return TEST_FILE_INIT_ERROR_MSG; } // seems like malformed xt file - no XPECT comment ? if (s.indexOf("#") < 0 || s.indexOf("~") < 0) { return s; } int posXT = s.indexOf("#"); int posTM = s.indexOf("~", posXT); text = s.substring(posXT + 1, posTM); } return text; }
Example 2
Source File: JUnitGradeSheetListener.java From public with Apache License 2.0 | 6 votes |
private GradingTest parseTest(final Description description, GradingPoints.PointsFormat pointsFormat) { final GradedTest annotation = description.getAnnotation(GradedTest.class); if (annotation == null) { throw new AssertionError("Test missing an annotation: " + description.getDisplayName()); } if (annotation.name().equals(GradedTest.DEFAULT_NAME)) { throw new IllegalArgumentException("Test without a name: " + description.getDisplayName()); } final String testDescription = annotation.description().equals(GradedTest.DEFAULT_DESCRIPTION) ? null : annotation.description(); final GradingTest test = new GradingTest(annotation.name(), testDescription, annotation.points(), pointsFormat); currentSuiteTests.put(description, test); return test; }
Example 3
Source File: IltConsumerJUnitListener.java From joynr with Apache License 2.0 | 6 votes |
public void testIgnored(Description description) { logger.info(">>> testIgnored called"); printDescription(description, 1); if (description == null || description.getDisplayName() == null) { logger.info("<<< testFinished called"); return; } TestSuiteResultsStore store = getStore(description); // create new entry TestCaseResult testCaseResult = new TestCaseResult(getTestCaseName(description), getTestSuiteClassName(description), //new Long(endTimeTestCase - startTimeTestCase).toString(), "0.000", "ignored", // status null, // no failure null // no systemOut ); store.testCaseResults.add(testCaseResult); store.skipped++; logger.info("<<< testIgnored called"); }
Example 4
Source File: IltConsumerJUnitListener.java From joynr with Apache License 2.0 | 6 votes |
@Override public void testIgnored(Description description) { logger.info(">>> testIgnored called"); printDescription(description, 1); if (description == null || description.getDisplayName() == null) { logger.info("<<< testFinished called"); return; } TestSuiteResultsStore store = getStore(description); // create new entry TestCaseResult testCaseResult = new TestCaseResult(getTestCaseName(description), getTestSuiteClassName(description), //new Long(endTimeTestCase - startTimeTestCase).toString(), "0.000", "ignored", // status null, // no failure null // no systemOut ); store.testCaseResults.add(testCaseResult); store.skipped++; logger.info("<<< testIgnored called"); }
Example 5
Source File: TestBigQuery.java From beam with Apache License 2.0 | 6 votes |
@Override public Statement apply(Statement base, Description description) { return new Statement() { @Override public void evaluate() throws Throwable { if (TestBigQuery.this.datasetService != null) { throw new AssertionError( "BigQuery test was not shutdown previously. " + "Table is'" + table + "'. " + "Current test: " + description.getDisplayName()); } try { initializeBigQuery(description); base.evaluate(); } finally { tearDown(); } } }; }
Example 6
Source File: JUnitGradeSheetListener.java From public with Apache License 2.0 | 5 votes |
private GradingSuite parseSuite(final Description description) { final GradedCategory annotation = description.getAnnotation(GradedCategory.class); final String suiteName = annotation.name().equals(GradedTest.DEFAULT_NAME) ? description.getDisplayName() : annotation.name(); final String suiteDescription = annotation.description().equals(GradedTest.DEFAULT_DESCRIPTION) ? null : annotation.description(); final String suiteGroup = annotation.group().equals(GradedCategory.DEFAULT_GROUP) ? null : annotation.group(); final GradingSuite suite = new GradingSuite(description.getClassName(), suiteName, suiteDescription, suiteGroup, annotation.pointsFormat()); for (final Description child : description.getChildren()) { if (isGradable(child)) { if (child.isTest()) { suite.tests.add(parseTest(child, annotation.pointsFormat())); } else { throw new AssertionError("Non-test child. How did you even do that?"); } } } return suite; }
Example 7
Source File: EclipseParameterized.java From tddl5 with Apache License 2.0 | 5 votes |
private static Description wrap(Description description) { String name = description.getDisplayName(); String fixedName = deparametrizedName(name); Description clonedDescription = Description.createSuiteDescription(fixedName, description.getAnnotations() .toArray(new Annotation[0])); for (Description child : description.getChildren()) { clonedDescription.addChild(wrap(child)); } return clonedDescription; }
Example 8
Source File: IltConsumerJUnitListener.java From joynr with Apache License 2.0 | 5 votes |
public String getTestCaseName(Description description) { String baseTestClassName; Pattern pattern = Pattern.compile("(.*)\\("); Matcher matcher = pattern.matcher(description.getDisplayName()); if (matcher.find()) { baseTestClassName = matcher.group(1); } else { baseTestClassName = description.getDisplayName(); } return baseTestClassName; }
Example 9
Source File: JUnitTestRunner.java From j2objc with Apache License 2.0 | 5 votes |
private String parseDescription(Description description) { String displayName = description.getDisplayName(); int p1 = displayName.indexOf("("); int p2 = displayName.indexOf(")"); if (p1 < 0 || p2 < 0 || p2 <= p1) { return displayName; } String methodName = displayName.substring(0, p1); String className = displayName.substring(p1 + 1, p2); return replaceAll(className) + " " + methodName; }
Example 10
Source File: IltConsumerJUnitListener.java From joynr with Apache License 2.0 | 5 votes |
public String getTestCaseName(Description description) { String baseTestClassName; Pattern pattern = Pattern.compile("(.*)\\("); Matcher matcher = pattern.matcher(description.getDisplayName()); if (matcher.find()) { baseTestClassName = matcher.group(1); } else { baseTestClassName = description.getDisplayName(); } return baseTestClassName; }
Example 11
Source File: RegExTestCaseFilter.java From bazel with Apache License 2.0 | 5 votes |
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); }
Example 12
Source File: SMTestSender.java From consulo with Apache License 2.0 | 5 votes |
public static String getMethodName(Description description) { try { return description.getMethodName(); } catch (NoSuchMethodError e) { final String displayName = description.getDisplayName(); Matcher matcher = Pattern.compile("(.*)\\((.*)\\)").matcher(displayName); if (matcher.matches()) { return matcher.group(1); } return null; } }
Example 13
Source File: JUnitGradeSheetListener.java From public with Apache License 2.0 | 5 votes |
private static GradingTest parseTest(final Description description, final List<GradingProblem> problems) { final GradedTest annotation = description.getAnnotation(GradedTest.class); if (annotation == null) { throw new AssertionError("Test missing an annotation: " + description.getDisplayName()); } return new GradingTest(annotation.value(), problems); }
Example 14
Source File: JUnitGradeSheetListener.java From public with Apache License 2.0 | 5 votes |
private static GradingSuite parseSuite(final Description description, final List<GradingTest> tests) { final GradedCategory annotation = description.getAnnotation(GradedCategory.class); if (annotation == null) { throw new AssertionError("Category missing an annotation: " + description.getDisplayName()); } return new GradingSuite(annotation.value(), tests); }
Example 15
Source File: AllureRunListener.java From allure-cucumberjvm with Apache License 2.0 | 5 votes |
/** * Find feature and story for given scenario * * @param scenarioName * @return {@link String[]} of ["<FEATURE_NAME>", "<STORY_NAME>"]s * @throws IllegalAccessException */ private String[] findFeatureByScenarioName(String scenarioName) throws IllegalAccessException { List<Description> testClasses = findTestClassesLevel(parentDescription.getChildren()); for (Description testClass : testClasses) { List<Description> features = findFeaturesLevel(testClass.getChildren()); //Feature cycle for (Description feature : features) { //Story cycle for (Description story : feature.getChildren()) { Object scenarioType = getTestEntityType(story); //Scenario if (scenarioType instanceof Scenario && story.getDisplayName().equals(scenarioName)) { return new String[]{feature.getDisplayName(), scenarioName}; //Scenario Outline } else if (scenarioType instanceof ScenarioOutline) { List<Description> examples = story.getChildren().get(0).getChildren(); // we need to go deeper :) for (Description example : examples) { if (example.getDisplayName().equals(scenarioName)) { return new String[]{feature.getDisplayName(), story.getDisplayName()}; } } } } } } return new String[]{"Feature: Undefined Feature", scenarioName}; }
Example 16
Source File: JUnitGradeSheetListener.java From public with Apache License 2.0 | 5 votes |
private GradingSuite parseSuite(final Description description) { final GradedCategory annotation = description.getAnnotation(GradedCategory.class); final String suiteName = annotation.name().equals(GradedTest.DEFAULT_NAME) ? description.getDisplayName() : annotation.name(); final String suiteDescription = annotation.description().equals(GradedTest.DEFAULT_DESCRIPTION) ? null : annotation.description(); final String suiteGroup = annotation.group().equals(GradedCategory.DEFAULT_GROUP) ? null : annotation.group(); final GradingSuite suite = new GradingSuite(description.getClassName(), suiteName, suiteDescription, suiteGroup, annotation.pointsFormat()); for (final Description child : description.getChildren()) { if (isGradable(child)) { if (child.isTest()) { suite.tests.add(parseTest(child, annotation.pointsFormat())); } else { throw new AssertionError("Non-test child. How did you even do that?"); } } } return suite; }
Example 17
Source File: IltConsumerJUnitListener.java From joynr with Apache License 2.0 | 5 votes |
@Override public void testFailure(Failure failure) { logger.info(">>> testFailure called"); Description description = failure.getDescription(); printDescription(description, 1); logger.info("- failure.getException() = " + failure.getException()); logger.info("- failure.getMessage() = " + failure.getMessage()); logger.info("- failure.getTestHeader() = " + failure.getTestHeader()); logger.info("- failure.getTrace() = " + failure.getTrace()); if (description == null || description.getDisplayName() == null) { logger.info("<<< testFinished called"); return; } // should have been created already in previous call to testStarted TestSuiteResultsStore store = getStore(description); TestCaseFailure testCaseFailure = new TestCaseFailure(failure.getMessage(), // message failure.getException().toString(), // type failure.getTrace() // text ); TestCaseResult testCaseResult = new TestCaseResult(getTestCaseName(description), getTestSuiteClassName(description), null, // test not finished yet, will be updated later "failed", // status testCaseFailure, // failure null // no systemOut ); store.testCaseResults.add(testCaseResult); store.failures++; // everything else will be done in testFinished, which is also // called for failed tests as well. logger.info("<<< testFailure called"); }
Example 18
Source File: N4IDEXpectFileNameUtil.java From n4js with Eclipse Public License 1.0 | 5 votes |
/***/ public static String getSuiteName(Description description) { String text = null; if (description.isSuite()) { String s = description.getDisplayName(); int posSemi = s.indexOf(":"); text = s.substring(0, posSemi); } return text; }
Example 19
Source File: IltConsumerJUnitListener.java From joynr with Apache License 2.0 | 4 votes |
public void testFinished(Description description) { logger.info(">>> testFinished called"); printDescription(description, 1); if (description == null || description.getDisplayName() == null) { logger.info("<<< testFinished called"); return; } TestSuiteResultsStore store = getStore(description); long endTimeTestCase = System.currentTimeMillis(); // this case may have failed and then we already have an entry. // check for description in list boolean found = false; for (int i = 0; i < store.testCaseResults.size(); i++) { if (store.testCaseResults.get(i).getName().equals(getTestCaseName(description))) { // update time for failed entry //testCaseResults.get(i).setTime(new Long(endTimeTestCase - startTimeTestCase).toString()); store.testCaseResults.get(i).setTime(getFormattedDuration(endTimeTestCase - startTimeTestCase)); found = true; break; } } if (found == false) { // create new entry TestCaseResult testCaseResult = new TestCaseResult(getTestCaseName(description), getTestSuiteClassName(description), //new Long(endTimeTestCase - startTimeTestCase).toString(), getFormattedDuration(endTimeTestCase - startTimeTestCase), "ok", // status null, // no failure null // no systemOut ); store.testCaseResults.add(testCaseResult); } store.tests++; store.consumedTime += (endTimeTestCase - startTimeTestCase); logger.info("<<< testFinished called"); }
Example 20
Source File: IltConsumerJUnitListener.java From joynr with Apache License 2.0 | 4 votes |
@Override public void testFinished(Description description) { logger.info(">>> testFinished called"); printDescription(description, 1); if (description == null || description.getDisplayName() == null) { logger.info("<<< testFinished called"); return; } TestSuiteResultsStore store = getStore(description); long endTimeTestCase = System.currentTimeMillis(); // this case may have failed and then we already have an entry. // check for description in list boolean found = false; for (int i = 0; i < store.testCaseResults.size(); i++) { if (store.testCaseResults.get(i).getName().equals(getTestCaseName(description))) { // update time for failed entry //testCaseResults.get(i).setTime(new Long(endTimeTestCase - startTimeTestCase).toString()); store.testCaseResults.get(i).setTime(getFormattedDuration(endTimeTestCase - startTimeTestCase)); found = true; break; } } if (found == false) { // create new entry TestCaseResult testCaseResult = new TestCaseResult(getTestCaseName(description), getTestSuiteClassName(description), //new Long(endTimeTestCase - startTimeTestCase).toString(), getFormattedDuration(endTimeTestCase - startTimeTestCase), "ok", // status null, // no failure null // no systemOut ); store.testCaseResults.add(testCaseResult); } store.tests++; store.consumedTime += (endTimeTestCase - startTimeTestCase); logger.info("<<< testFinished called"); }