本文整理了Java中org.testng.TestNG.setUseDefaultListeners()
方法的一些代码示例,展示了TestNG.setUseDefaultListeners()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TestNG.setUseDefaultListeners()
方法的具体详情如下:
包路径:org.testng.TestNG
类名称:TestNG
方法名:setUseDefaultListeners
[英]If this method is passed true before run(), the default listeners will not be used.
代码示例来源:origin: cbeust/testng
private void triggerTest(Class<?>... cls) {
TestNG tng = create(mTempDirectory.toPath(), cls);
tng.setUseDefaultListeners(true);
tng.run();
}
代码示例来源:origin: cbeust/testng
private static File runTest(Class<?> clazz) {
String suiteName = UUID.randomUUID().toString();
File fileLocation = createDirInTempDir(suiteName);
TestNG testng = create(fileLocation.toPath(), clazz);
testng.setUseDefaultListeners(true);
testng.run();
return new File(fileLocation, RuntimeBehavior.FILE_NAME);
}
}
代码示例来源:origin: cbeust/testng
public static TestNG create() {
TestNG result = new TestNG();
result.setUseDefaultListeners(false);
result.setVerbose(0);
return result;
}
代码示例来源:origin: cbeust/testng
@Test(description = "GITHUB-435")
public void ensureSuiteLevelPackageIsAppliedToAllTests() throws IOException {
Parser parser = new Parser("src/test/resources/xml/issue435.xml");
List<XmlSuite> suites = parser.parseToList();
XmlSuite xmlsuite = suites.get(0);
assertThat(xmlsuite.getTests().get(0).getClasses().size()).isEqualTo(0);
TestNG testNG = create();
testNG.setXmlSuites(suites);
testNG.setUseDefaultListeners(false);
testNG.run();
assertThat(xmlsuite.getTests().get(0).getClasses().size()).isEqualTo(1);
}
代码示例来源:origin: cbeust/testng
private File runTests(RUN_TYPES runType) {
String suiteName = UUID.randomUUID().toString();
File fileLocation = createDirInTempDir(suiteName);
Class[] classes = {};
switch (runType) {
case WITH_FAILURES:
classes = new Class[] {WithFailure.class};
break;
case WITHOUT_FAILURES:
classes = new Class[] {WithoutFailure.class};
break;
case MIXED_MODE:
classes = new Class[] {WithFailure.class, WithoutFailure.class};
}
TestNG testNG = create(fileLocation.toPath(), classes);
testNG.setUseDefaultListeners(true);
try {
testNG.run();
} catch (AssertionError e) {
// catch all assertion failures. Our intent is not assertions of the test class.
}
return fileLocation;
}
代码示例来源:origin: cbeust/testng
@Test(description = "GITHUB-1674")
public void ensureSuiteLevelBeanshellIsAppliedToAllTests() throws IOException {
PrintStream current = System.out;
StringOutputStream stream = new StringOutputStream();
try {
System.setOut(new PrintStream(stream));
Parser parser = new Parser("src/test/resources/xml/issue1674.xml");
List<XmlSuite> suites = parser.parseToList();
XmlSuite xmlsuite = suites.get(0);
assertThat(xmlsuite.getTests().get(0).getMethodSelectors().size()).isEqualTo(0);
TestNG testNG = create();
testNG.setXmlSuites(suites);
testNG.setUseDefaultListeners(false);
testNG.run();
assertThat(xmlsuite.getTests().get(0).getMethodSelectors().size()).isEqualTo(1);
assertThat(stream.toString()).contains(Arrays.asList("rajni", "kamal", "mgr"));
} finally {
System.setOut(current);
}
}
代码示例来源:origin: cbeust/testng
@BeforeMethod
public void init() {
m_tng = new TestNG();
m_tng.setOutputDirectory(OutputDirectoryPatch.getOutputDirectory());
m_tng.setVerbose(0);
m_tng.setUseDefaultListeners(false);
}
代码示例来源:origin: cbeust/testng
@Test(description = "GITHUB-1668")
public void ensureNoExceptionsAreRaisedWhenMethodSelectorsDefinedAtSuiteLevel()
throws IOException {
Parser parser = new Parser("src/test/resources/xml/issue1668.xml");
List<XmlSuite> suites = parser.parseToList();
XmlSuite xmlsuite = suites.get(0);
TestNG testNG = create();
testNG.setXmlSuites(suites);
testNG.setUseDefaultListeners(false);
testNG.run();
// Trigger a call to "toXml()" to ensure that there is no exception raised.
assertThat(xmlsuite.toXml()).isNotEmpty();
}
代码示例来源:origin: cbeust/testng
@Test
public void testPruningOfDuplicateReporter() {
XmlSuite xmlSuite = createXmlSuite("Suite");
XmlTest xmlTest = createXmlTest(xmlSuite, "Test");
createXmlClass(xmlTest, UniqueReporterInjectionSample1.class);
createXmlClass(xmlTest, UniqueReporterInjectionSample2.class);
TestNG tng = create(xmlSuite);
tng.setUseDefaultListeners(false);
tng.addListener((ITestNGListener) new ReporterListenerForIssue1227());
tng.run();
//Since we have another reporting listener that is injected via the service loader file
//reporting listeners size will now have to be three (because the ExitCodeListener is also a reporter backed listener).
Assert.assertEquals(tng.getReporters().size(),3);
Assert.assertEquals(ReporterListenerForIssue1227.counter, 1);
}
代码示例来源:origin: cbeust/testng
@Test(description = "Make sure only one listener is created and not 2^3")
public void run()
{
final TestNG tng = new TestNG();
tng.setUseDefaultListeners(false);
tng.setListenerClasses(Arrays.asList(TestListenerAdapter.class, SimpleReporter.class));
final List<XmlSuite> suites = createSuites();
tng.setXmlSuites(suites);
tng.setVerbose(0);
tng.run();
// Reporter.log(tng.getSuiteListeners().size() + "", true);
// for (final XmlSuite xmlSuite : suites)
// {
// Reporter.log(xmlSuite.getName() + ": " + xmlSuite.getListeners().size(), true);
// }
}
代码示例来源:origin: cbeust/testng
private void triggerTest(String packageName, boolean applyGroupSelectionAtTest) {
final XmlSuite suite = createXmlSuite("1297_suite");
final XmlTest xmlTest = createXmlTestWithPackages(suite, "1297_test", packageName);
if (applyGroupSelectionAtTest) {
createXmlGroups(xmlTest, "run");
} else {
createXmlGroups(suite, "run");
}
TestNG tng = create(mTempDirectory.toPath(), suite);
tng.setUseDefaultListeners(true);
tng.run();
}
代码示例来源:origin: org.testng/testng
setUseDefaultListeners("true".equalsIgnoreCase(cla.useDefaultListeners));
代码示例来源:origin: cbeust/testng
setUseDefaultListeners("true".equalsIgnoreCase(cla.useDefaultListeners));
代码示例来源:origin: cbeust/testng
@Test
public void failedSuiteShouldHaveParameters() {
Map<String, String> suiteParams = create("suite");
Map<String, String> testParams = create("test");
Map<String, String> classParams = create("class");
Map<String, String> methodParams = create("method");
// In testng-failed.xml, suite will have both origin suite parameters and children tests
// parameters.
XmlSuite suite = createXmlSuite(suiteParams);
TestNG tng = create(mTempDirectory.toPath(), suite);
tng.setUseDefaultListeners(true);
XmlTest test = createXmlTest(suite, suite.getName(), testParams);
XmlClass clazz = createXmlClass(test, FailedReporterSampleTest.class, classParams);
createXmlInclude(clazz, "f2", methodParams);
tng.run();
runAssertions(
mTempDirectory,
"<parameter name=\"%s\" value=\"%s\"/>",
new String[] {"suiteParam", "testParam", "classParam", "methodParam"});
}
代码示例来源:origin: stackoverflow.com
TestNG testNG = new TestNG();
testNG.setUseDefaultListeners(false);
...
代码示例来源:origin: apache/maven-surefire
@Override
public void configure( TestNG testng, Map<String, String> options )
throws TestSetFailedException
{
System.out.println( "\n\n\n\nCONFIGURING TESTNG\n\n\n\n" );
// kind of ugly, but listeners are configured differently
final String listeners = options.remove( "listener" );
// DGF In 4.7, default listeners dump XML files in the surefire-reports directory,
// confusing the report plugin. This was fixed in later versions.
testng.setUseDefaultListeners( false );
configureInstance( testng, options );
// TODO: we should have the Profile so that we can decide if this is needed or not
testng.setListenerClasses( loadListenerClasses( listeners ) );
}
代码示例来源:origin: org.apache.maven.surefire/surefire-testng
@Override
public void configure( TestNG testng, Map<String, String> options )
throws TestSetFailedException
{
System.out.println( "\n\n\n\nCONFIGURING TESTNG\n\n\n\n" );
// kind of ugly, but listeners are configured differently
final String listeners = options.remove( "listener" );
// DGF In 4.7, default listeners dump XML files in the surefire-reports directory,
// confusing the report plugin. This was fixed in later versions.
testng.setUseDefaultListeners( false );
configureInstance( testng, options );
// TODO: we should have the Profile so that we can decide if this is needed or not
testng.setListenerClasses( loadListenerClasses( listeners ) );
}
代码示例来源:origin: opengeospatial/teamengine
setTestSuites(driver, this.testngConfig);
driver.setVerbose(0);
driver.setUseDefaultListeners(this.useDefaultListeners);
UUID runId = UUID.randomUUID();
File runDir = new File(this.outputDir, runId.toString());
代码示例来源:origin: ops4j/org.ops4j.pax.exam2
private void runSuite(OutputStream os, Class<?> clazz, String methodName) throws IOException {
ObjectOutputStream oos = new ObjectOutputStream(os);
TestNG testNG = new TestNG();
testNG.setUseDefaultListeners(false);
testNG.setVerbose(0);
ContainerResultListener listener = new ContainerResultListener(oos);
testNG.addListener(listener);
XmlSuite suite = new XmlSuite();
suite.setName("PaxExamInternal");
XmlTest xmlTest = new XmlTest(suite);
XmlClass xmlClass = new XmlClass(clazz);
xmlTest.getClasses().add(xmlClass);
if (methodName != null) {
XmlInclude xmlInclude = new XmlInclude(methodName);
xmlClass.getIncludedMethods().add(xmlInclude);
}
testNG.setXmlSuites(Arrays.asList(suite));
testNG.run();
}
}
代码示例来源:origin: ops4j/org.ops4j.pax.exam2
private void runTestWithTestNG(TestDescription description, TestListener listener) {
TestNG testNG = new TestNG();
testNG.setVerbose(0);
testNG.setUseDefaultListeners(false);
ContainerResultListener resultListener = new ContainerResultListener(listener);
testNG.addListener(resultListener);
XmlSuite suite = new XmlSuite();
suite.setName("PaxExamInternal");
XmlTest xmlTest = new XmlTest(suite);
XmlClass xmlClass = new XmlClass(description.getClassName());
xmlTest.getClasses().add(xmlClass);
if (description.getMethodName() != null) {
XmlInclude xmlInclude = new XmlInclude(description.getMethodName());
xmlClass.getIncludedMethods().add(xmlInclude);
}
testNG.setXmlSuites(Collections.singletonList(suite));
testNG.run();
}
内容来源于网络,如有侵权,请联系作者删除!