Search in sources :

Example 1 with TestCompleteEvent

use of org.gradle.api.internal.tasks.testing.TestCompleteEvent in project gradle by gradle.

the class GenericJUnitTestEventAdapter method testIgnored.

public void testIgnored(TestDescriptorInternal descriptor) {
    resultProcessor.started(descriptor, startEvent());
    resultProcessor.completed(descriptor.getId(), new TestCompleteEvent(clock.getCurrentTime(), TestResult.ResultType.SKIPPED));
}
Also used : TestCompleteEvent(org.gradle.api.internal.tasks.testing.TestCompleteEvent)

Example 2 with TestCompleteEvent

use of org.gradle.api.internal.tasks.testing.TestCompleteEvent in project gradle by gradle.

the class TestNGTestResultProcessorAdapter method onConfigurationFailure.

@Override
public void onConfigurationFailure(ITestResult testResult) {
    synchronized (lock) {
        if (!failedConfigurations.add(testResult)) {
            // workaround for bug in TestNG 6.2 (apparently fixed in some 6.3.x): listener is notified twice per event
            return;
        }
    }
    // Synthesise a test for the broken configuration method
    TestDescriptorInternal test = new DefaultTestMethodDescriptor(idGenerator.generateId(), testResult.getMethod().getTestClass().getName(), testResult.getMethod().getMethodName());
    resultProcessor.started(test, new TestStartEvent(testResult.getStartMillis()));
    resultProcessor.failure(test.getId(), testResult.getThrowable());
    resultProcessor.completed(test.getId(), new TestCompleteEvent(testResult.getEndMillis(), TestResult.ResultType.FAILURE));
}
Also used : DefaultTestMethodDescriptor(org.gradle.api.internal.tasks.testing.DefaultTestMethodDescriptor) TestDescriptorInternal(org.gradle.api.internal.tasks.testing.TestDescriptorInternal) TestStartEvent(org.gradle.api.internal.tasks.testing.TestStartEvent) TestCompleteEvent(org.gradle.api.internal.tasks.testing.TestCompleteEvent)

Example 3 with TestCompleteEvent

use of org.gradle.api.internal.tasks.testing.TestCompleteEvent in project gradle by gradle.

the class TestMainAction method run.

@Override
public void run() {
    RootTestSuiteDescriptor suite = new RootTestSuiteDescriptor(rootTestSuiteId, displayName, testTaskOperationId);
    resultProcessor.started(suite, new TestStartEvent(clock.getCurrentTime()));
    try {
        processor.startProcessing(resultProcessor);
        try {
            detector.run();
        } finally {
            processor.stop();
        }
    } finally {
        resultProcessor.completed(suite.getId(), new TestCompleteEvent(clock.getCurrentTime()));
    }
}
Also used : TestStartEvent(org.gradle.api.internal.tasks.testing.TestStartEvent) TestCompleteEvent(org.gradle.api.internal.tasks.testing.TestCompleteEvent)

Example 4 with TestCompleteEvent

use of org.gradle.api.internal.tasks.testing.TestCompleteEvent in project gradle by gradle.

the class GenericJUnitTestEventAdapter method testFailure.

public void testFailure(T identifier, TestDescriptorInternal descriptor, Throwable exception) {
    TestDescriptorInternal testInternal;
    synchronized (lock) {
        testInternal = executing.get(identifier);
    }
    boolean needEndEvent = false;
    if (testInternal == null) {
        // This can happen when, for example, a @BeforeClass or @AfterClass method fails
        needEndEvent = true;
        testInternal = descriptor;
        resultProcessor.started(testInternal, startEvent());
    }
    resultProcessor.failure(testInternal.getId(), exception);
    if (needEndEvent) {
        resultProcessor.completed(testInternal.getId(), new TestCompleteEvent(clock.getCurrentTime()));
    }
}
Also used : TestDescriptorInternal(org.gradle.api.internal.tasks.testing.TestDescriptorInternal) TestCompleteEvent(org.gradle.api.internal.tasks.testing.TestCompleteEvent)

Example 5 with TestCompleteEvent

use of org.gradle.api.internal.tasks.testing.TestCompleteEvent in project gradle by gradle.

the class GenericJUnitTestEventAdapter method testFinished.

public void testFinished(T identifier) {
    long endTime = clock.getCurrentTime();
    TestDescriptorInternal testInternal;
    TestResult.ResultType resultType;
    synchronized (lock) {
        testInternal = executing.remove(identifier);
        if (testInternal == null && executing.size() == 1) {
            // Assume that test has renamed itself (this can actually happen)
            testInternal = executing.values().iterator().next();
            executing.clear();
        }
        assert testInternal != null : String.format("Unexpected end event for %s", identifier);
        resultType = assumptionFailed.remove(identifier) ? TestResult.ResultType.SKIPPED : null;
    }
    resultProcessor.completed(testInternal.getId(), new TestCompleteEvent(endTime, resultType));
}
Also used : TestDescriptorInternal(org.gradle.api.internal.tasks.testing.TestDescriptorInternal) TestResult(org.gradle.api.tasks.testing.TestResult) TestCompleteEvent(org.gradle.api.internal.tasks.testing.TestCompleteEvent)

Aggregations

TestCompleteEvent (org.gradle.api.internal.tasks.testing.TestCompleteEvent)10 TestStartEvent (org.gradle.api.internal.tasks.testing.TestStartEvent)5 TestDescriptorInternal (org.gradle.api.internal.tasks.testing.TestDescriptorInternal)4 DefaultTestMethodDescriptor (org.gradle.api.internal.tasks.testing.DefaultTestMethodDescriptor)3 TestResult (org.gradle.api.tasks.testing.TestResult)2 Scanner (java.util.Scanner)1 Matcher (java.util.regex.Matcher)1 DefaultTestClassDescriptor (org.gradle.api.internal.tasks.testing.DefaultTestClassDescriptor)1 DefaultTestDescriptor (org.gradle.api.internal.tasks.testing.DefaultTestDescriptor)1 DefaultTestOutputEvent (org.gradle.api.internal.tasks.testing.DefaultTestOutputEvent)1 ITestNGMethod (org.testng.ITestNGMethod)1