use of org.gradle.api.internal.tasks.testing.DefaultTestClassDescriptor in project gradle by gradle.
the class TestWorkerProgressListener method createProgressLoggerDescription.
private String createProgressLoggerDescription(TestDescriptorInternal testDescriptor) {
DecoratingTestDescriptor decoratingTestDescriptor = (DecoratingTestDescriptor) testDescriptor;
DefaultTestClassDescriptor defaultTestClassDescriptor = (DefaultTestClassDescriptor) decoratingTestDescriptor.getDescriptor();
return "Executing test " + JavaClassNameFormatter.abbreviateJavaPackage(defaultTestClassDescriptor.getClassName(), MAX_TEST_NAME_LENGTH);
}
use of org.gradle.api.internal.tasks.testing.DefaultTestClassDescriptor in project gradle by gradle.
the class TestClassExecutionEventGenerator method testClassStarted.
@Override
public void testClassStarted(String testClassName, String testClassDisplayName) {
currentTestClass = new DefaultTestClassDescriptor(idGenerator.generateId(), testClassName, testClassDisplayName);
resultProcessor.started(currentTestClass, new TestStartEvent(clock.getCurrentTime()));
}
use of org.gradle.api.internal.tasks.testing.DefaultTestClassDescriptor 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));
}
use of org.gradle.api.internal.tasks.testing.DefaultTestClassDescriptor in project gradle by gradle.
the class XCTestScraper method text.
@Override
public void text(String textFragment) {
textBuilder.append(textFragment);
if (!textFragment.endsWith(SystemProperties.getInstance().getLineSeparator())) {
return;
}
String text = textBuilder.toString();
textBuilder = new StringBuilder();
synchronized (testDescriptors) {
Scanner scanner = new Scanner(text).useDelimiter("'");
if (scanner.hasNext()) {
String token = scanner.next().trim();
if (token.equals("Test Suite")) {
// Test Suite 'PassingTestSuite' started at 2017-10-30 10:45:47.828
String testSuite = scanner.next();
if (testSuite.equals("All tests") || testSuite.equals("Selected tests") || testSuite.endsWith(".xctest")) {
// ignore these test suites
return;
}
String status = scanner.next();
boolean started = status.contains("started at");
if (started) {
// Using DefaultTestClassDescriptor to fake JUnit test
TestDescriptorInternal testDescriptor = new DefaultTestClassDescriptor(idGenerator.generateId(), testSuite);
processor.started(testDescriptor, new TestStartEvent(clock.getCurrentTime()));
testDescriptors.push(new XCTestDescriptor(testDescriptor));
} else {
XCTestDescriptor xcTestDescriptor = testDescriptors.pop();
lastDescriptor = xcTestDescriptor.getDescriptorInternal();
TestDescriptorInternal testDescriptor = xcTestDescriptor.getDescriptorInternal();
TestResult.ResultType resultType = TestResult.ResultType.SUCCESS;
boolean failed = status.contains("failed at");
if (failed) {
resultType = TestResult.ResultType.FAILURE;
}
processor.completed(testDescriptor.getId(), new TestCompleteEvent(clock.getCurrentTime(), resultType));
}
} else if (token.equals("Test Case")) {
// (macOS) Looks like: Test Case '-[AppTest.PassingTestSuite testCanPassTestCaseWithAssertion]' started.
// (Linux) Looks like: Test Case 'PassingTestSuite.testCanPassTestCaseWithAssertion' started.
String testSuiteAndCase = scanner.next();
String[] splits = testSuiteAndCase.replace('[', ' ').replace(']', ' ').split("[. ]");
String testSuite;
String testCase;
if (OperatingSystem.current().isMacOsX()) {
testSuite = splits[2];
testCase = splits[3];
} else {
testSuite = splits[0];
testCase = splits[1];
}
String status = scanner.next().trim();
boolean started = status.contains("started");
if (started) {
TestDescriptorInternal testDescriptor = new DefaultTestMethodDescriptor(idGenerator.generateId(), testSuite, testCase);
processor.started(testDescriptor, new TestStartEvent(clock.getCurrentTime()));
testDescriptors.push(new XCTestDescriptor(testDescriptor));
} else {
XCTestDescriptor xcTestDescriptor = testDescriptors.pop();
lastDescriptor = xcTestDescriptor.getDescriptorInternal();
TestDescriptorInternal testDescriptor = xcTestDescriptor.getDescriptorInternal();
TestResult.ResultType resultType = TestResult.ResultType.SUCCESS;
boolean failed = status.contains("failed");
if (failed) {
resultType = TestResult.ResultType.FAILURE;
processor.failure(testDescriptor.getId(), new Throwable(Joiner.on(TextUtil.getPlatformLineSeparator()).join(xcTestDescriptor.getMessages())));
}
processor.completed(testDescriptor.getId(), new TestCompleteEvent(clock.getCurrentTime(), resultType));
}
} else {
XCTestDescriptor xcTestDescriptor = testDescriptors.peek();
if (xcTestDescriptor != null) {
TestDescriptorInternal testDescriptor = xcTestDescriptor.getDescriptorInternal();
processor.output(testDescriptor.getId(), new DefaultTestOutputEvent(destination, text));
Matcher failureMessageMatcher = TEST_FAILURE_PATTERN.matcher(text);
if (failureMessageMatcher.find()) {
String testSuite = failureMessageMatcher.group(2);
String testCase = failureMessageMatcher.group(3);
String message = failureMessageMatcher.group(4);
if (testDescriptor.getClassName().equals(testSuite) && testDescriptor.getName().equals(testCase)) {
xcTestDescriptor.getMessages().add(message);
}
}
// If no current test can be associated to the output, the last known descriptor is used.
// See https://bugs.swift.org/browse/SR-1127 for more information.
} else if (lastDescriptor != null) {
processor.output(lastDescriptor.getId(), new DefaultTestOutputEvent(destination, text));
}
}
}
}
}
Aggregations