本文整理了Java中org.testng.TestNG.addListener()
方法的一些代码示例,展示了TestNG.addListener()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TestNG.addListener()
方法的具体详情如下:
包路径:org.testng.TestNG
类名称:TestNG
方法名:addListener
暂无
代码示例来源:origin: org.testng/testng
/**
* @deprecated Use addListener(ITestNGListener) instead
*/
// TODO remove later
@Deprecated
public void addExecutionListener(IExecutionListener l) {
addListener((ITestNGListener) l);
}
代码示例来源:origin: org.testng/testng
private void addListeners(XmlSuite s) {
for (String listenerName : s.getListeners()) {
Class<?> listenerClass = ClassHelper.forName(listenerName);
// If specified listener does not exist, a TestNGException will be thrown
if(listenerClass == null) {
throw new TestNGException("Listener " + listenerName + " was not found in project's classpath");
}
ITestNGListener listener = (ITestNGListener) ClassHelper.newInstance(listenerClass);
addListener(listener);
}
// Add the child suite listeners
List<XmlSuite> childSuites = s.getChildSuites();
for (XmlSuite c : childSuites) {
addListeners(c);
}
}
代码示例来源:origin: org.testng/testng
/**
* @deprecated Use addListener(ITestNGListener) instead
*/
// TODO remove later
@Deprecated
public void addListener(IInvokedMethodListener listener) {
addListener((ITestNGListener) listener);
}
代码示例来源:origin: org.testng/testng
/**
* @deprecated Use addListener(ITestNGListener) instead
*/
// TODO remove later
@Deprecated
public void addListener(ISuiteListener listener) {
addListener((ITestNGListener) listener);
}
代码示例来源:origin: org.testng/testng
/**
* @deprecated Use addListener(ITestNGListener) instead
*/
// TODO remove later
@Deprecated
public void addListener(IClassListener listener) {
addListener((ITestNGListener) listener);
}
代码示例来源:origin: org.testng/testng
/**
* @deprecated Use addListener(ITestNGListener) instead
*/
// TODO remove later
@Deprecated
public void addListener(IReporter listener) {
addListener((ITestNGListener) listener);
}
代码示例来源:origin: org.testng/testng
/**
* @deprecated Use addListener(ITestNGListener) instead
*/
// TODO remove later
@Deprecated
public void addInvokedMethodListener(IInvokedMethodListener listener) {
addListener((ITestNGListener) listener);
}
代码示例来源:origin: org.testng/testng
/**
* @deprecated Use addListener(ITestNGListener) instead
*/
// TODO remove later
@Deprecated
public void addListener(ITestListener listener) {
addListener((ITestNGListener) listener);
}
代码示例来源:origin: org.testng/testng
/**
* @deprecated Use addListener(ITestNGListener) instead
*/
// TODO remove later
@Deprecated
public void addAlterSuiteListener(IAlterSuiteListener l) {
addListener((ITestNGListener) l);
}
代码示例来源:origin: org.testng/testng
/**
* Define which listeners to user for this run.
*
* @param classes A list of classes, which must be either ISuiteListener,
* ITestListener or IReporter
*/
public void setListenerClasses(List<Class<? extends ITestNGListener>> classes) {
for (Class<? extends ITestNGListener> cls: classes) {
addListener(ClassHelper.newInstance(cls));
}
}
代码示例来源:origin: org.testng/testng
/**
* @deprecated Use addListener(ITestNGListener) instead
*/
// TODO remove later /!\ Caution: IntelliJ is using it. Check with @akozlova before removing it
@Deprecated
public void addListener(Object listener) {
if (! (listener instanceof ITestNGListener))
{
exitWithError("Listener " + listener
+ " must be one of ITestListener, ISuiteListener, IReporter, "
+ " IAnnotationTransformer, IMethodInterceptor or IInvokedMethodListener");
}
addListener((ITestNGListener) listener);
}
代码示例来源:origin: cbeust/testng
/**
* Define which listeners to user for this run.
*
* @param classes A list of classes, which must be either ISuiteListener, ITestListener or
* IReporter
*/
public void setListenerClasses(List<Class<? extends ITestNGListener>> classes) {
for (Class<? extends ITestNGListener> cls : classes) {
addListener(ClassHelper.newInstance(cls));
}
}
代码示例来源:origin: org.testng/testng
/**
* Using reflection to remain Java 5 compliant.
*/
private void addServiceLoaderListeners() {
Iterable<ITestNGListener> loader = m_serviceLoaderClassLoader != null ?
ServiceLoader.load(ITestNGListener.class, m_serviceLoaderClassLoader)
: ServiceLoader.load(ITestNGListener.class);
for (ITestNGListener l : loader) {
Utils.log("[TestNG]", 2, "Adding ServiceLoader listener:" + l);
addListener(l);
addServiceLoaderListener(l);
}
}
代码示例来源:origin: org.testng/testng
private void addReporter(ReporterConfig reporterConfig) {
IReporter instance = reporterConfig.newReporterInstance();
if (instance != null) {
addListener(instance);
} else {
LOGGER.warn("Could not find reporter class : " + reporterConfig.getClassName());
}
}
代码示例来源:origin: org.testng/testng
private void initializeDefaultListeners() {
this.exitCodeListener = new org.testng.internal.ExitCodeListener();
addListener((ITestNGListener) this.exitCodeListener);
if (m_useDefaultListeners) {
addReporter(SuiteHTMLReporter.class);
addReporter(Main.class);
addReporter(FailedReporter.class);
addReporter(XMLReporter.class);
if (System.getProperty("oldTestngEmailableReporter") != null) {
addReporter(EmailableReporter.class);
} else if (System.getProperty("noEmailableReporter") == null) {
addReporter(EmailableReporter2.class);
}
addReporter(JUnitReportReporter.class);
if (m_verbose != null && m_verbose > 4) {
addListener(new VerboseReporter("[TestNG] "));
}
}
}
代码示例来源:origin: cbeust/testng
@Test
public void testGitHub1307() {
TestNG tng = create(FactoryWithAnonymousTestsSample.class);
InvokedMethodNameListener listener = new InvokedMethodNameListener();
tng.addListener(listener);
tng.run();
assertThat(listener.getFailedMethodNames()).isEmpty();
assertThat(listener.getSkippedMethodNames()).isEmpty();
assertThat(listener.getSucceedMethodNames()).containsExactly("test");
}
}
代码示例来源:origin: cbeust/testng
@Test
public void testDuplicationFunctionality() {
XmlSuite suite = createXmlSuite("suite", "test", TestClassSample.class);
TestNG testng = create(suite);
MethodMultiplyingInterceptor tla = new MethodMultiplyingInterceptor();
testng.addListener(tla);
testng.run();
int expected = tla.getMultiplyCount() + tla.getOriginalMethodCount();
assertThat(tla.getPassedTests().size()).isEqualTo(expected);
}
代码示例来源:origin: cbeust/testng
private ITestClass runTestWithDefaultMethods() {
TestNG tng = create(TestA.class);
TestClassListener listener = new TestClassListener();
tng.addListener(listener);
tng.run();
return listener.testClass;
}
代码示例来源:origin: spring-projects/spring-framework
@Test
@Ignore("Fails against TestNG 6.11")
public void runTestAndAssertCounters() throws Exception {
TrackingTestNGTestListener listener = new TrackingTestNGTestListener();
TestNG testNG = new TestNG();
testNG.addListener((ITestNGListener) listener);
testNG.setTestClasses(new Class<?>[] {this.clazz});
testNG.setVerbose(0);
testNG.run();
String name = this.clazz.getSimpleName();
assertEquals("tests started for [" + name + "] ==> ", this.expectedTestStartCount, listener.testStartCount);
assertEquals("successful tests for [" + name + "] ==> ", this.expectedTestSuccessCount, listener.testSuccessCount);
assertEquals("failed tests for [" + name + "] ==> ", this.expectedFailureCount, listener.testFailureCount);
assertEquals("failed configurations for [" + name + "] ==> ",
this.expectedFailedConfigurationsCount, listener.failedConfigurationsCount);
}
代码示例来源:origin: spring-projects/spring-framework
private void runTestClassAndAssertStats(Class<?> testClass, int expectedTestCount) {
final int expectedTestFailureCount = 0;
final int expectedTestStartedCount = expectedTestCount;
final int expectedTestFinishedCount = expectedTestCount;
final TrackingTestNGTestListener listener = new TrackingTestNGTestListener();
final TestNG testNG = new TestNG();
testNG.addListener((ITestNGListener) listener);
testNG.setTestClasses(new Class<?>[] { testClass });
testNG.setVerbose(0);
testNG.run();
assertEquals("Failures for test class [" + testClass + "].", expectedTestFailureCount,
listener.testFailureCount);
assertEquals("Tests started for test class [" + testClass + "].", expectedTestStartedCount,
listener.testStartCount);
assertEquals("Successful tests for test class [" + testClass + "].", expectedTestFinishedCount,
listener.testSuccessCount);
}
内容来源于网络,如有侵权,请联系作者删除!