forked from testng-team/testng
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SuiteRunner could not be initial by default Configuration
Fixes testng-team#2743
- Loading branch information
Showing
4 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
testng-core/src/test/java/test/configuration/issue2743/SuiteRunnerIssueTestSample.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package test.configuration.issue2743; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Comparator; | ||
import java.util.List; | ||
import org.testng.IClassListener; | ||
import org.testng.IInvokedMethodListener; | ||
import org.testng.ISuite; | ||
import org.testng.ITestNGMethod; | ||
import org.testng.ITestRunnerFactory; | ||
import org.testng.SuiteRunner; | ||
import org.testng.TestRunner; | ||
import org.testng.annotations.Test; | ||
import org.testng.internal.Configuration; | ||
import org.testng.internal.IConfiguration; | ||
import org.testng.reporters.JUnitXMLReporter; | ||
import org.testng.reporters.TestHTMLReporter; | ||
import org.testng.xml.XmlClass; | ||
import org.testng.xml.XmlSuite; | ||
import org.testng.xml.XmlTest; | ||
|
||
public class SuiteRunnerIssueTestSample { | ||
public static SuiteRunner suiteRunner; | ||
|
||
@Test | ||
public void suiteRunnerSample() { | ||
XmlSuite suite = new XmlSuite(); | ||
suite.setName("TestSuite"); | ||
XmlTest test = new XmlTest(suite); | ||
test.setName("ChildTests"); | ||
List<XmlClass> classes = new ArrayList<>(); | ||
classes.add(new XmlClass("test.configuration.suites.IssueTest")); | ||
test.setXmlClasses(classes); | ||
|
||
final IConfiguration configuration = new Configuration(); | ||
final boolean useDefaultListeners = true; | ||
|
||
suiteRunner = | ||
new SuiteRunner( | ||
configuration, | ||
suite, | ||
"outputDir", | ||
new ITestRunnerFactory() { | ||
|
||
@Override | ||
public TestRunner newTestRunner( | ||
ISuite suite, | ||
XmlTest xmlTest, | ||
Collection<IInvokedMethodListener> listeners, | ||
List<IClassListener> classListeners) { | ||
TestRunner runner = | ||
new TestRunner( | ||
configuration, | ||
suite, | ||
xmlTest, | ||
false /* skipFailedInvocationCounts */, | ||
listeners, | ||
classListeners); | ||
if (useDefaultListeners) { | ||
runner.addListener(new TestHTMLReporter()); | ||
runner.addListener(new JUnitXMLReporter()); | ||
} | ||
|
||
return runner; | ||
} | ||
}, | ||
useDefaultListeners, | ||
Comparator.comparingInt(ITestNGMethod::getPriority)); | ||
suiteRunner.run(); | ||
} | ||
} |