Java Code Examples for org.junit.runner.Description#createSuiteDescription()

The following examples show how to use org.junit.runner.Description#createSuiteDescription() . 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: TestSuiteModel.java    From bazel with Apache License 2.0 6 votes vote down vote up
/**
 * Build a model with the given name, including the given suites. This method should be called
 * before any command line filters are applied.
 *
 * <p>The given {@code properties} map will be applied to the root {@link TestSuiteNode}.
 */
public TestSuiteModel build(
    String suiteName, Map<String, String> properties, Description... topLevelSuites) {
  if (buildWasCalled) {
    throw new IllegalStateException("Builder.build() was already called");
  }
  buildWasCalled = true;
  if (shardingEnvironment.isShardingEnabled()) {
    shardingFilter = getShardingFilter(topLevelSuites);
  }
  rootNode = new TestSuiteNode(Description.createSuiteDescription(suiteName), properties);
  for (Description topLevelSuite : topLevelSuites) {
    addTestSuite(rootNode, topLevelSuite);
    rootNode.getDescription().addChild(topLevelSuite);
  }
  return new TestSuiteModel(this);
}
 
Example 2
Source File: ConsoleSpammingMockitoJUnitRunnerTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void shouldDelegateToGetDescription() throws Exception {
    //given
    final Description expectedDescription = Description.createSuiteDescription(this.getClass());
    runner = new ConsoleSpammingMockitoJUnitRunner(loggerStub, new RunnerImplStub() {
        public Description getDescription() {
            return expectedDescription;
        }
    });
    
    //when
    Description description = runner.getDescription();
    
    //then
    assertEquals(expectedDescription, description);
}
 
Example 3
Source File: ConsoleSpammingMockitoJUnitRunnerTest.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void shouldDelegateToGetDescription() throws Exception {
    //given
    final Description expectedDescription = Description.createSuiteDescription(this.getClass());
    runner = new ConsoleSpammingMockitoJUnitRunner(loggerStub, new RunnerImplStub() {
        public Description getDescription() {
            return expectedDescription;
        }
    });
    
    //when
    Description description = runner.getDescription();
    
    //then
    assertEquals(expectedDescription, description);
}
 
Example 4
Source File: AbstractMultiTestRunner.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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);
    }
}
 
Example 5
Source File: CourgetteJUnitRunner.java    From courgette-jvm with MIT License 6 votes vote down vote up
private void createDescription() {
    if (description == null) {
        description = Description.createSuiteDescription(getName());
    }

    getChildren()
            .stream()
            .distinct()
            .forEach(feature -> {
                if (!featureDescriptionNames.contains(feature.getName())) {
                    Description featureDescription = Description.createTestDescription("", feature.getName());
                    description.addChild(featureDescription);
                    featureDescriptions.put(feature, featureDescription);
                    featureDescriptionNames.add(feature.getName());
                }
            });
}
 
Example 6
Source File: TestSuiteNodeTest.java    From bazel with Apache License 2.0 5 votes vote down vote up
@Test
public void testProperties() {
  ImmutableMap<String, String> properties = ImmutableMap.of("key", "value");
  testSuiteNode = new TestSuiteNode(Description.createSuiteDescription("suite"), properties);

  TestResult result = testSuiteNode.getResult();
  assertThat(result.getProperties()).containsExactlyEntriesIn(properties);
}
 
Example 7
Source File: RunUntilFailure.java    From phoenix with Apache License 2.0 5 votes vote down vote up
private Description describeRepeatTest(FrameworkMethod method) {  
    int times = method.getAnnotation(Repeat.class).value();  

    Description description = Description.createSuiteDescription(  
            testName(method) + " [" + times + " times]",  
            method.getAnnotations());  

    for (int i = 1; i <= times; i++) {  
        description.addChild(Description.createTestDescription(  
                getTestClass().getJavaClass(),  
                testName(method) + "-" + i));  
    }  
    return description;  
}
 
Example 8
Source File: PinpointPluginTestRunner.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
@Override
public Description getDescription() {
    Description description = Description.createSuiteDescription(getName(), getRunnerAnnotations());
    for (FrameworkMethod child : getFilteredChildren()) {
        description.addChild(describeChild(child));
    }
    return description;
}
 
Example 9
Source File: AbstractMultiTestRunner.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
private void initDescription() {
    initExecutions();
    if (description == null) {
        description = Description.createSuiteDescription(target);
        for (Execution execution : executions) {
            execution.addDescriptions(description);
        }
    }
}
 
Example 10
Source File: FeatureInfo.java    From karate with MIT License 5 votes vote down vote up
public FeatureInfo(Feature feature, String tagSelector) {
    this.feature = feature;
    description = Description.createSuiteDescription(feature.getNameForReport(), feature.getResource().getPackageQualifiedName());
    FeatureContext featureContext = new FeatureContext(null, feature, tagSelector);
    CallContext callContext = new CallContext(null, true, this);
    exec = new ExecutionContext(null, System.currentTimeMillis(), featureContext, callContext, null, null, null);
    unit = new FeatureExecutionUnit(exec);
    unit.init();
    for (ScenarioExecutionUnit u : unit.getScenarioExecutionUnits()) {
        Description scenarioDescription = getScenarioDescription(u.scenario);
        description.addChild(scenarioDescription);
    }
}
 
Example 11
Source File: AllureRunListener.java    From allure-cucumberjvm with Apache License 2.0 5 votes vote down vote up
public String getSuiteUid(Description description) throws IllegalAccessException {
    String suiteName = description.getClassName();
    if (!description.isSuite()) {
        suiteName = extractClassName(description);
    }
    if (!getSuites().containsKey(suiteName)) {
        //Fix NPE
        Description suiteDescription = Description.createSuiteDescription(suiteName);
        testSuiteStarted(suiteDescription, suiteName);
    }
    return getSuites().get(suiteName);
}
 
Example 12
Source File: LoggingListenerTests.java    From crate with Apache License 2.0 5 votes vote down vote up
public void testInvalidMethodTestLoggingAnnotation() throws Exception {
    final LoggingListener loggingListener = new LoggingListener();

    final Description suiteDescription = Description.createSuiteDescription(InvalidMethod.class);

    loggingListener.testRunStarted(suiteDescription);

    final Method method = InvalidMethod.class.getMethod("invalidMethod");
    final TestLogging annotation = method.getAnnotation(TestLogging.class);
    Description testDescription = Description.createTestDescription(InvalidMethod.class, "invalidMethod", annotation);
    final IllegalArgumentException e =
        expectThrows(IllegalArgumentException.class, () -> loggingListener.testStarted(testDescription));
    assertThat(e.getMessage(), equalTo("invalid test logging annotation [abc:INFO:WARN]"));
}
 
Example 13
Source File: AllureRunListener.java    From allure1 with Apache License 2.0 5 votes vote down vote up
public String getSuiteUid(Description description) {
    String suiteName = description.getClassName();
    if (!getSuites().containsKey(suiteName)) {
        Class testClass = description.getTestClass();
        Description suiteDescription;
        if (testClass != null) {
            suiteDescription = Description.createSuiteDescription(testClass);
        } else {
            suiteDescription = Description.createSuiteDescription(description.getClassName());
        }
        testSuiteStarted(suiteDescription);
    }
    return getSuites().get(suiteName);
}
 
Example 14
Source File: DefaultServer.java    From quarkus-http with Apache License 2.0 5 votes vote down vote up
private Description describeRepeatTest(FrameworkMethod method) {

        Description description = Description.createSuiteDescription(
                testName(method) + " [" + runs + " times]",
                method.getAnnotations());

        for (int i = 1; i <= runs; i++) {
            description.addChild(Description.createTestDescription(
                    getTestClass().getJavaClass(),
                    "[" + i + "] " + testName(method)));
        }
        return description;
    }
 
Example 15
Source File: AbstractMultiTestRunner.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public CannotExecuteRunner(String displayName, Class<?> testClass, Throwable failure) {
    description = Description.createSuiteDescription(String.format("%s(%s)", displayName, testClass.getName()));
    this.failure = failure;
}
 
Example 16
Source File: SpectrumHelper.java    From spectrum with MIT License 4 votes vote down vote up
@Override
public Description getDescription() {
  // empty suite

  return Description.createSuiteDescription(clazz);
}
 
Example 17
Source File: TestRequestBuilder.java    From android-test with Apache License 2.0 4 votes vote down vote up
@Override
public Description getDescription() {
  return Description.createSuiteDescription("no tests found");
}
 
Example 18
Source File: AbstractMultiTestRunner.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public CannotExecuteRunner(String displayName, Class<?> testClass, Throwable failure) {
    description = Description.createSuiteDescription(String.format("%s(%s)", displayName, testClass.getName()));
    this.failure = failure;
}
 
Example 19
Source File: AntXmlResultWriterTest.java    From bazel with Apache License 2.0 4 votes vote down vote up
private TestSuiteNode createTestSuite() {
  Description suite = Description.createSuiteDescription(TestCaseNodeTest.TestSuite.class);
  TestSuiteNode parent = new TestSuiteNode(suite);
  root.addTestSuite(parent);
  return parent;
}
 
Example 20
Source File: RawTestImpl.java    From tm4e with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public Description getDescription() {
	return Description.createSuiteDescription(desc);
}