Search in sources :

Example 1 with TestDescriptorInternal

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

the class ClientForwardingTestOperationListener method started.

@Override
public void started(BuildOperationDescriptor buildOperation, OperationStartEvent startEvent) {
    Object details = buildOperation.getDetails();
    if (details instanceof ExecuteTaskBuildOperationDetails) {
        Task task = ((ExecuteTaskBuildOperationDetails) details).getTask();
        if (!(task instanceof Test)) {
            return;
        }
        runningTasks.put(buildOperation.getId(), task.getPath());
    } else if (details instanceof ExecuteTestBuildOperationType.Details) {
        ExecuteTestBuildOperationType.Details testOperationDetails = (ExecuteTestBuildOperationType.Details) details;
        TestDescriptorInternal testDescriptor = (TestDescriptorInternal) testOperationDetails.getTestDescriptor();
        eventConsumer.dispatch(new DefaultTestStartedProgressEvent(testOperationDetails.getStartTime(), adapt(testDescriptor)));
    }
}
Also used : Task(org.gradle.api.Task) ExecuteTaskBuildOperationDetails(org.gradle.api.execution.internal.ExecuteTaskBuildOperationDetails) ExecuteTaskBuildOperationDetails(org.gradle.api.execution.internal.ExecuteTaskBuildOperationDetails) TestDescriptorInternal(org.gradle.api.internal.tasks.testing.TestDescriptorInternal) Test(org.gradle.api.tasks.testing.Test) DefaultTestStartedProgressEvent(org.gradle.tooling.internal.provider.events.DefaultTestStartedProgressEvent) ExecuteTestBuildOperationType(org.gradle.api.internal.tasks.testing.operations.ExecuteTestBuildOperationType)

Example 2 with TestDescriptorInternal

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

the class StateTrackingTestResultProcessor method started.

@Override
public final void started(TestDescriptorInternal test, TestStartEvent event) {
    TestDescriptorInternal parent = null;
    if (event.getParentId() != null) {
        parent = executing.get(event.getParentId()).test;
    }
    TestState state = new TestState(new DecoratingTestDescriptor(test, parent), event, executing);
    TestState oldState = executing.put(test.getId(), state);
    if (oldState != null) {
        throw new IllegalArgumentException(String.format("Received a start event for %s with duplicate id '%s'.", test, test.getId()));
    }
    delegate.started(state.test, event);
}
Also used : TestDescriptorInternal(org.gradle.api.internal.tasks.testing.TestDescriptorInternal) DecoratingTestDescriptor(org.gradle.api.internal.tasks.testing.DecoratingTestDescriptor)

Example 3 with TestDescriptorInternal

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

the class TestNGTestResultProcessorAdapter method onBeforeClass.

@Override
public void onBeforeClass(ITestClass testClass) {
    TestDescriptorInternal testInternal;
    Object parentId;
    synchronized (lock) {
        testInternal = new DefaultTestClassDescriptor(idGenerator.generateId(), testClass.getName());
        testClassId.put(testClass, testInternal.getId());
        parentId = xmlTestIds.get(testClass.getXmlTest());
    }
    resultProcessor.started(testInternal, new TestStartEvent(clock.getCurrentTime(), parentId));
}
Also used : TestDescriptorInternal(org.gradle.api.internal.tasks.testing.TestDescriptorInternal) DefaultTestClassDescriptor(org.gradle.api.internal.tasks.testing.DefaultTestClassDescriptor) TestStartEvent(org.gradle.api.internal.tasks.testing.TestStartEvent)

Example 4 with TestDescriptorInternal

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

the class TestNGTestResultProcessorAdapter method onStart.

@Override
public void onStart(ISuite suite) {
    TestDescriptorInternal testInternal;
    synchronized (lock) {
        if (suiteId.containsKey(suite)) {
            // Can get duplicate start events
            return;
        }
        Object id = idGenerator.generateId();
        testInternal = new DefaultTestSuiteDescriptor(id, suite.getName());
        suiteId.put(suite, testInternal.getId());
    }
    resultProcessor.started(testInternal, new TestStartEvent(clock.getCurrentTime()));
}
Also used : TestDescriptorInternal(org.gradle.api.internal.tasks.testing.TestDescriptorInternal) TestStartEvent(org.gradle.api.internal.tasks.testing.TestStartEvent) DefaultTestSuiteDescriptor(org.gradle.api.internal.tasks.testing.DefaultTestSuiteDescriptor)

Example 5 with TestDescriptorInternal

use of org.gradle.api.internal.tasks.testing.TestDescriptorInternal 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)

Aggregations

TestDescriptorInternal (org.gradle.api.internal.tasks.testing.TestDescriptorInternal)12 TestStartEvent (org.gradle.api.internal.tasks.testing.TestStartEvent)6 TestCompleteEvent (org.gradle.api.internal.tasks.testing.TestCompleteEvent)4 DefaultTestMethodDescriptor (org.gradle.api.internal.tasks.testing.DefaultTestMethodDescriptor)3 DefaultTestClassDescriptor (org.gradle.api.internal.tasks.testing.DefaultTestClassDescriptor)2 DefaultTestSuiteDescriptor (org.gradle.api.internal.tasks.testing.DefaultTestSuiteDescriptor)2 TestResult (org.gradle.api.tasks.testing.TestResult)2 Scanner (java.util.Scanner)1 Matcher (java.util.regex.Matcher)1 Task (org.gradle.api.Task)1 ExecuteTaskBuildOperationDetails (org.gradle.api.execution.internal.ExecuteTaskBuildOperationDetails)1 DecoratingTestDescriptor (org.gradle.api.internal.tasks.testing.DecoratingTestDescriptor)1 DefaultTestOutputEvent (org.gradle.api.internal.tasks.testing.DefaultTestOutputEvent)1 ExecuteTestBuildOperationType (org.gradle.api.internal.tasks.testing.operations.ExecuteTestBuildOperationType)1 Test (org.gradle.api.tasks.testing.Test)1 DefaultTestStartedProgressEvent (org.gradle.tooling.internal.provider.events.DefaultTestStartedProgressEvent)1 ITestNGMethod (org.testng.ITestNGMethod)1