Search in sources :

Example 6 with TestDescriptorInternal

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

the class TestExecutionResultEvaluator method getTaskPath.

private String getTaskPath(TestDescriptorInternal givenDescriptor) {
    TestDescriptorInternal descriptor = givenDescriptor;
    while (descriptor.getOwnerBuildOperationId() == null && descriptor.getParent() != null) {
        descriptor = descriptor.getParent();
    }
    String taskPath = runningTasks.get(descriptor.getOwnerBuildOperationId());
    if (taskPath == null) {
        throw new IllegalStateException("No parent task for test " + givenDescriptor);
    }
    return taskPath;
}
Also used : TestDescriptorInternal(org.gradle.api.internal.tasks.testing.TestDescriptorInternal)

Example 7 with TestDescriptorInternal

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

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

Example 9 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(ITestContext iTestContext) {
    TestDescriptorInternal testInternal;
    Object parentId;
    synchronized (lock) {
        Object id = idGenerator.generateId();
        testInternal = new DefaultTestSuiteDescriptor(id, iTestContext.getName());
        parentId = suiteId.get(iTestContext.getSuite());
        xmlTestIds.put(iTestContext.getCurrentXmlTest(), id);
        testId.put(iTestContext, testInternal.getId());
        for (ITestNGMethod method : iTestContext.getAllTestMethods()) {
            testMethodParentId.put(method, testInternal.getId());
        }
    }
    resultProcessor.started(testInternal, new TestStartEvent(iTestContext.getStartDate().getTime(), parentId));
}
Also used : TestDescriptorInternal(org.gradle.api.internal.tasks.testing.TestDescriptorInternal) ITestNGMethod(org.testng.ITestNGMethod) TestStartEvent(org.gradle.api.internal.tasks.testing.TestStartEvent) DefaultTestSuiteDescriptor(org.gradle.api.internal.tasks.testing.DefaultTestSuiteDescriptor)

Example 10 with TestDescriptorInternal

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

the class TestNGTestResultProcessorAdapter method onTestStart.

@Override
public void onTestStart(ITestResult iTestResult) {
    TestDescriptorInternal testInternal;
    Object parentId;
    synchronized (lock) {
        String name = calculateTestCaseName(iTestResult);
        testInternal = new DefaultTestMethodDescriptor(idGenerator.generateId(), iTestResult.getTestClass().getName(), name);
        Object oldTestId = testMethodId.put(iTestResult, testInternal.getId());
        assert oldTestId == null : "Apparently some other test has started but it hasn't finished. " + "Expect the resultProcessor to break. " + "Don't expect to see this assertion stack trace due to the current architecture";
        parentId = testMethodParentId.get(iTestResult.getMethod());
        assert parentId != null;
    }
    resultProcessor.started(testInternal, new TestStartEvent(iTestResult.getStartMillis(), parentId));
    if (iTestResult.getThrowable() instanceof UnrepresentableParameterException) {
        throw (UnrepresentableParameterException) iTestResult.getThrowable();
    }
}
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)

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