Search in sources :

Example 1 with TestStartEvent

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

the class TestNGTestResultProcessorAdapter method onConfigurationFailure.

@Override
public void onConfigurationFailure(ITestResult testResult) {
    ITestNGMethod testMethod = testResult.getMethod();
    ITestClass testClass = testMethod.getTestClass();
    TestClassInfo classInfo;
    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;
        }
        classInfo = this.testClassInfo.get(testClass);
    }
    // Synthesise a test for the broken configuration method
    TestDescriptorInternal test = new DefaultTestMethodDescriptor(idGenerator.generateId(), testClass.getName(), testMethod.getMethodName());
    Object parentId = classInfo == null ? null : classInfo.id;
    resultProcessor.started(test, new TestStartEvent(testResult.getStartMillis(), parentId));
    resultProcessor.failure(test.getId(), testResult.getThrowable());
    resultProcessor.completed(test.getId(), new TestCompleteEvent(testResult.getEndMillis(), TestResult.ResultType.FAILURE));
}
Also used : ITestClass(org.testng.ITestClass) DefaultTestMethodDescriptor(org.gradle.api.internal.tasks.testing.DefaultTestMethodDescriptor) TestDescriptorInternal(org.gradle.api.internal.tasks.testing.TestDescriptorInternal) ITestNGMethod(org.testng.ITestNGMethod) TestStartEvent(org.gradle.api.internal.tasks.testing.TestStartEvent) TestCompleteEvent(org.gradle.api.internal.tasks.testing.TestCompleteEvent)

Example 2 with TestStartEvent

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

the class TestNGTestResultProcessorAdapter method onBeforeClass.

@Override
public void onBeforeClass(ITestClass testClass) {
    TestDescriptorInternal testInternal = null;
    Object parentId = null;
    synchronized (lock) {
        TestClassInfo info = testClassInfo.get(testClass);
        if (info != null) {
            info.incrementStartedCount();
        } else {
            testInternal = new DefaultTestClassDescriptor(idGenerator.generateId(), testClass.getName());
            testClassInfo.put(testClass, new TestClassInfo(testInternal.getId()));
            parentId = xmlTestIds.get(testClass.getXmlTest());
            for (ITestNGMethod method : testClass.getTestMethods()) {
                testMethodParentId.put(method, testInternal.getId());
            }
        }
    }
    if (testInternal != null) {
        resultProcessor.started(testInternal, new TestStartEvent(clock.getCurrentTime(), parentId));
    }
}
Also used : TestDescriptorInternal(org.gradle.api.internal.tasks.testing.TestDescriptorInternal) ITestNGMethod(org.testng.ITestNGMethod) DefaultTestClassDescriptor(org.gradle.api.internal.tasks.testing.DefaultTestClassDescriptor) TestStartEvent(org.gradle.api.internal.tasks.testing.TestStartEvent)

Example 3 with TestStartEvent

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

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

the class TestClassExecutionEventGenerator method testClassStarted.

@Override
public void testClassStarted(String testClassName) {
    currentTestClass = new DefaultTestClassDescriptor(idGenerator.generateId(), testClassName);
    resultProcessor.started(currentTestClass, new TestStartEvent(clock.getCurrentTime()));
}
Also used : DefaultTestClassDescriptor(org.gradle.api.internal.tasks.testing.DefaultTestClassDescriptor) TestStartEvent(org.gradle.api.internal.tasks.testing.TestStartEvent)

Example 5 with TestStartEvent

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

the class TestMainAction method run.

@Override
public void run() {
    TestDescriptorInternal suite = new RootTestSuiteDescriptor(rootTestSuiteId, displayName);
    resultProcessor.started(suite, new TestStartEvent(clock.getCurrentTime()));
    try {
        processor.startProcessing(resultProcessor);
        try {
            detector.run();
        } finally {
            // Release worker lease while waiting for tests to complete
            // Do not release any other locks, so that other test tasks from the same project do not start running
            WorkerLeaseRegistry.WorkerLease currentWorkerLease = workerLeaseService.getCurrentWorkerLease();
            workerLeaseService.withoutLocks(Collections.singletonList(currentWorkerLease), new Runnable() {

                @Override
                public void run() {
                    processor.stop();
                }
            });
        }
    } finally {
        resultProcessor.completed(suite.getId(), new TestCompleteEvent(clock.getCurrentTime()));
    }
}
Also used : TestDescriptorInternal(org.gradle.api.internal.tasks.testing.TestDescriptorInternal) WorkerLeaseRegistry(org.gradle.internal.work.WorkerLeaseRegistry) TestStartEvent(org.gradle.api.internal.tasks.testing.TestStartEvent) TestCompleteEvent(org.gradle.api.internal.tasks.testing.TestCompleteEvent)

Aggregations

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