in surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGProvider.java [89:143]
public RunResult invoke(Object forkTestSet) throws TestSetFailedException {
if (isFailFast() && commandsReader != null) {
registerPleaseStopListener();
}
ReporterFactory reporterFactory = providerParameters.getReporterFactory();
TestReportListener<TestOutputReportEntry> reporter = reporterFactory.createTestReportListener();
RunResult runResult;
try {
if (isTestNGXmlTestSuite(testRequest)) {
TestNGReporter testNGReporter = createTestNGReporter(reporter);
testNGReporter.setRunMode(NORMAL_RUN);
/*
* {@link org.apache.maven.surefire.api.report.ConsoleOutputCapture#startCapture(ConsoleOutputReceiver)}
* called in prior to initializing variable {@link #testsToRun}
*/
startCapture(testNGReporter);
if (commandsReader != null) {
commandsReader.awaitStarted();
}
TestNGXmlTestSuite testNGXmlTestSuite = newXmlSuite();
testNGXmlTestSuite.locateTestSets();
testNGXmlTestSuite.execute(testNGReporter);
} else {
TestNGReporter testNGReporter = createTestNGReporter(reporter);
testNGReporter.setRunMode(NORMAL_RUN);
/*
* {@link org.apache.maven.surefire.api.report.ConsoleOutputCapture#startCapture(ConsoleOutputReceiver)}
* called in prior to initializing variable {@link #testsToRun}
*/
startCapture(testNGReporter);
final TestsToRun testsToRun;
if (forkTestSet instanceof TestsToRun) {
testsToRun = (TestsToRun) forkTestSet;
} else if (forkTestSet instanceof Class) {
testsToRun = fromClass((Class<?>) forkTestSet);
} else {
testsToRun = scanClassPath();
}
if (commandsReader != null) {
registerShutdownListener(testsToRun);
commandsReader.awaitStarted();
}
TestNGDirectoryTestSuite suite = newDirectorySuite();
suite.execute(testsToRun, testNGReporter);
}
} finally {
runResult = reporterFactory.close();
}
return runResult;
}