Search in sources :

Example 66 with Description

use of org.junit.runner.Description in project joynr by bmwcarit.

the class IltConsumerJUnitListener method testAssumptionFailure.

// the following methods are called by JUnit framework
// called when an atomic test flags that it assumes a condition
// that is false
public void testAssumptionFailure(Failure failure) {
    LOG.info(">>> testAssumptionFailure called");
    Description description = failure.getDescription();
    printDescription(description, 1);
    // should have been created already in previous call to testStarted
    TestSuiteResultsStore store = getStore(description);
    store.errors++;
    LOG.info("<<< testAssumptionFailure called");
}
Also used : Description(org.junit.runner.Description)

Example 67 with Description

use of org.junit.runner.Description in project ant by apache.

the class CustomJUnit4TestAdapterCache method getNotifier.

public RunNotifier getNotifier(final TestResult result) {
    final IgnoredTestResult resultWrapper = (IgnoredTestResult) result;
    RunNotifier notifier = new RunNotifier();
    notifier.addListener(new RunListener() {

        @Override
        public void testFailure(Failure failure) throws Exception {
            result.addError(asTest(failure.getDescription()), failure.getException());
        }

        @Override
        public void testFinished(Description description) throws Exception {
            result.endTest(asTest(description));
        }

        @Override
        public void testStarted(Description description) throws Exception {
            result.startTest(asTest(description));
        }

        @Override
        public void testIgnored(Description description) throws Exception {
            if (resultWrapper != null) {
                resultWrapper.testIgnored(asTest(description));
            }
        }

        @Override
        public void testAssumptionFailure(Failure failure) {
            if (resultWrapper != null) {
                resultWrapper.testAssumptionFailure(asTest(failure.getDescription()), failure.getException());
            }
        }
    });
    return notifier;
}
Also used : RunNotifier(org.junit.runner.notification.RunNotifier) Description(org.junit.runner.Description) Failure(org.junit.runner.notification.Failure) RunListener(org.junit.runner.notification.RunListener)

Example 68 with Description

use of org.junit.runner.Description in project junit-dataprovider by TNG.

the class DataProviderFilterTest method testShouldRunShouldReturnTrueWhenDescriptionHavingSomeRandomCodeBetweenMethodNameAndClass.

@Test
public void testShouldRunShouldReturnTrueWhenDescriptionHavingSomeRandomCodeBetweenMethodNameAndClass() {
    // Given:
    doReturn("Method testMain(com.tngtech.Clazz)").when(filter).describe();
    Description description = setupDescription(true, "testMain 298zBZ=)& %(/$(=93A SD4)i(qzt)487 5z2 59isf&(com.tngtech.Clazz)");
    // When:
    boolean result = underTest.shouldRun(description);
    // Then:
    assertThat(result).isTrue();
}
Also used : Description(org.junit.runner.Description) Test(org.junit.Test)

Example 69 with Description

use of org.junit.runner.Description in project junit-dataprovider by TNG.

the class DataProviderFilterTest method testShouldRunShouldReturnTrueWhenDescriptionHaveOnlyMethodNameAndEqualsExactlyWithoutPackage.

@Test
public void testShouldRunShouldReturnTrueWhenDescriptionHaveOnlyMethodNameAndEqualsExactlyWithoutPackage() {
    // Given:
    doReturn("Method testMain(Clazz)").when(filter).describe();
    Description description = setupDescription(true, "testMain(Clazz)");
    // When:
    boolean result = underTest.shouldRun(description);
    // Then:
    assertThat(result).isTrue();
}
Also used : Description(org.junit.runner.Description) Test(org.junit.Test)

Example 70 with Description

use of org.junit.runner.Description in project junit-dataprovider by TNG.

the class DataProviderFilterTest method testShouldRunShouldReturnFalseWhenDescriptionDoesNotHaveExpectedClassName.

@Test
public void testShouldRunShouldReturnFalseWhenDescriptionDoesNotHaveExpectedClassName() {
    // Given:
    doReturn("Method testMain[1: ](com.tngtech.Clazz)").when(filter).describe();
    Description description = setupDescription(true, "testMain[1: ](com.tngtech.ClazzOther)");
    // When:
    boolean result = underTest.shouldRun(description);
    // Then:
    assertThat(result).isFalse();
}
Also used : Description(org.junit.runner.Description) Test(org.junit.Test)

Aggregations

Description (org.junit.runner.Description)309 Test (org.junit.Test)119 Failure (org.junit.runner.notification.Failure)57 Result (org.junit.runner.Result)32 ArrayList (java.util.ArrayList)25 RunListener (org.junit.runner.notification.RunListener)23 IOException (java.io.IOException)22 Request (org.junit.runner.Request)21 Method (java.lang.reflect.Method)18 JUnitCore (org.junit.runner.JUnitCore)17 Test (org.junit.jupiter.api.Test)14 Filter (org.junit.runner.manipulation.Filter)14 File (java.io.File)13 Runner (org.junit.runner.Runner)13 Statement (org.junit.runners.model.Statement)13 LoggingListener (org.elasticsearch.test.junit.listeners.LoggingListener)12 RunNotifier (org.junit.runner.notification.RunNotifier)12 JUnit4TestListener (com.intellij.junit4.JUnit4TestListener)10 ComparisonFailure (org.junit.ComparisonFailure)10 Description.createTestDescription (org.junit.runner.Description.createTestDescription)9