当前位置: 首页>>代码示例>>Java>>正文


Java ITestListener类代码示例

本文整理汇总了Java中org.testng.ITestListener的典型用法代码示例。如果您正苦于以下问题:Java ITestListener类的具体用法?Java ITestListener怎么用?Java ITestListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ITestListener类属于org.testng包,在下文中一共展示了ITestListener类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onTestSkipped

import org.testng.ITestListener; //导入依赖的package包/类
/**
 * [ITestListener]
 * Invoked each time a test is skipped.
 *
 * @param result {@code ITestResult} containing information about the run test
 * @see ITestResult#SKIP
 */
@Override
public void onTestSkipped(ITestResult result) {
    
    // >>>>> ENTER workaround for TestNG bug
    // https://github.com/cbeust/testng/issues/1602
    ITestContext context = result.getTestContext();
    IInvokedMethod method = new InvokedMethod(
                    result.getTestClass(), result.getMethod(), System.currentTimeMillis(), result);
    
    beforeInvocation(method, result, context);
    // <<<<< LEAVE workaround for TestNG bug
    
    synchronized (testListeners) {
        for (ITestListener testListener : testListeners) {
            testListener.onTestSkipped(result);
        }
    }
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:26,代码来源:ListenerChain.java

示例2: createAdapter

import org.testng.ITestListener; //导入依赖的package包/类
public ITestListener createAdapter(ITestListener listener) {
    Class<?> testNG6Class = tryLoadClass("org.testng.IConfigurationListener2");
    if (testNG6Class != null) {
        return createProxy(testNG6Class, listener);
    }

    Class<?> testNG5Class = tryLoadClass("org.testng.internal.IConfigurationListener");
    if (testNG5Class != null) {
        return createProxy(testNG5Class, listener);
    }

    throw new UnsupportedOperationException("Neither found interface 'org.testng.IConfigurationListener2' nor interface 'org.testng.internal.IConfigurationListener'. Which version of TestNG are you using?");
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:14,代码来源:TestNGListenerAdapterFactory.java

示例3: createProxy

import org.testng.ITestListener; //导入依赖的package包/类
private ITestListener createProxy(Class<?> configListenerClass, final ITestListener listener) {
    Class<?>[] interfaces = new Class<?>[]{ITestListener.class, ISuiteListener.class, configListenerClass};
    return (ITestListener) Proxy.newProxyInstance(classLoader, interfaces, new AdaptedListener(listener));
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:5,代码来源:TestNGListenerAdapterFactory.java

示例4: onStart

import org.testng.ITestListener; //导入依赖的package包/类
public void onStart( ISuite suite ) {

        // get the run name specified by the user
        String runName = CommonConfigurator.getInstance().getRunName();
        if (runName.equals(CommonConfigurator.DEFAULT_RUN_NAME)) {
            // the user did not specify a run name, use the one from TestNG
            runName = suite.getName();
        }

        // the following is needed in case when more than one RUN are executed sequentially
        // we need to clear some temporary data in the other listener we use
        TestNG testNgInstance = TestNG.getDefault();
        // cleanup the class level listener
        new AtsTestngClassListener().resetTempData();
        // cleanup the test level listener
        for (ITestListener listener : testNgInstance.getTestListeners()) {
            if (listener instanceof AtsTestngTestListener) {
                ((AtsTestngTestListener) listener).resetTempData();
            }
        }

        // start a new run
        String hostNameIp = "";
        try {
            InetAddress addr = InetAddress.getLocalHost();
            hostNameIp = addr.getHostName() + "/" + addr.getHostAddress();

        } catch (UnknownHostException uhe) {
            hostNameIp = null;
        }

        logger.startRun(runName, CommonConfigurator.getInstance().getOsName(),
                        CommonConfigurator.getInstance().getProductName(),
                        CommonConfigurator.getInstance().getVersionName(),
                        CommonConfigurator.getInstance().getBuildName(), hostNameIp);

        logSystemInformation();
        logClassPath();
    }
 
开发者ID:Axway,项目名称:ats-framework,代码行数:40,代码来源:AtsTestngSuiteListener.java

示例5: onTestSuccess

import org.testng.ITestListener; //导入依赖的package包/类
/**
 * [ITestListener]
 * Invoked each time a test succeeds.
 *
 * @param result {@code ITestResult} containing information about the run test
 * @see ITestResult#SUCCESS
 */
@Override
public void onTestSuccess(ITestResult result) {
    synchronized (testListeners) {
        for (ITestListener testListener : testListeners) {
            testListener.onTestSuccess(result);
        }
    }
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:16,代码来源:ListenerChain.java

示例6: onTestFailure

import org.testng.ITestListener; //导入依赖的package包/类
/**
 * [ITestListener]
 * Invoked each time a test fails.
 *
 * @param result {@code ITestResult} containing information about the run test
 * @see ITestResult#FAILURE
 */
@Override
public void onTestFailure(ITestResult result) {
    synchronized (testListeners) {
        for (ITestListener testListener : testListeners) {
            testListener.onTestFailure(result);
        }
    }
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:16,代码来源:ListenerChain.java

示例7: onStart

import org.testng.ITestListener; //导入依赖的package包/类
/**
 * [ITestListener]
 * Invoked after the test class is instantiated and before
 * any configuration method is called.
 * 
 * @param context context for the test run
 */
@Override
public void onStart(ITestContext context) {
    synchronized (testListeners) {
        for (ITestListener testListener : Lists.reverse(testListeners)) {
            testListener.onStart(context);
        }
    }
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:16,代码来源:ListenerChain.java

示例8: onFinish

import org.testng.ITestListener; //导入依赖的package包/类
/**
 * [ITestListener]
 * Invoked after all the tests have run and all their
 * Configuration methods have been called.
 * 
 * @param context context for the test run
 */
@Override
public void onFinish(ITestContext context) {
    synchronized (testListeners) {
        for (ITestListener testListener : testListeners) {
            testListener.onFinish(context);
        }
    }
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:16,代码来源:ListenerChain.java

示例9: shouldBeRecordingIfCustomVideoAnnotation

import org.testng.ITestListener; //导入依赖的package包/类
@Test
@Video()
public void shouldBeRecordingIfCustomVideoAnnotation() {
  System.setProperty("video.save.mode","FAILED_ONLY");
  System.setProperty("recorder.type","FFMPEG");

  ITestResult result = prepareMock(TestNgCustomVideoListenerTest.class, testMethod);
  ITestListener listener = new CustomVideoListener();
  listener.onTestStart(result);
  sleep(5);
  listener.onTestFailure(result);
  File file = MonteRecorder.getLastRecording();
  assertTrue(file.exists());
}
 
开发者ID:SergeyPirogov,项目名称:video-recorder-java,代码行数:15,代码来源:TestNGVideoListenerTest.java

示例10: addTestListenerIfNotAddedBefore

import org.testng.ITestListener; //导入依赖的package包/类
public static void addTestListenerIfNotAddedBefore(TestRunner tr,
		Class<?> listenerClass) throws IllegalAccessException,
		InstantiationException {
	for (ITestListener listnr : tr.getTestListeners()) {
		if (listenerClass.isInstance(listnr)) {
			return;
		}
	}
	tr.addTestListener((ITestListener) listenerClass.newInstance());
}
 
开发者ID:web-auto,项目名称:wtf-core,代码行数:11,代码来源:WTFTest.java

示例11: adaptListener

import org.testng.ITestListener; //导入依赖的package包/类
private ITestListener adaptListener(ITestListener listener) {
    TestNGListenerAdapterFactory factory = new TestNGListenerAdapterFactory(applicationClassLoader);
    return factory.createAdapter(listener);
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:5,代码来源:TestNGTestClassProcessor.java

示例12: AdaptedListener

import org.testng.ITestListener; //导入依赖的package包/类
private AdaptedListener(ITestListener delegate) {
    this.delegate = delegate;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:4,代码来源:TestNGListenerAdapterFactory.java

示例13: onTestStart

import org.testng.ITestListener; //导入依赖的package包/类
/**
 * [ITestListener]
 * Invoked each time before a test will be invoked.
 * The {@code ITestResult} is only partially filled with the references to
 * class, method, start millis and status.
 *
 * @param result the partially filled {@code ITestResult}
 * @see ITestResult#STARTED
 */
@Override
public void onTestStart(ITestResult result) {
    synchronized(testListeners) {
        for (ITestListener testListener : Lists.reverse(testListeners)) {
            testListener.onTestStart(result);
        }
    }
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:18,代码来源:ListenerChain.java

示例14: onTestFailedButWithinSuccessPercentage

import org.testng.ITestListener; //导入依赖的package包/类
/**
 * [ITestListener]
 * Invoked each time a method fails but has been annotated with
 * successPercentage and this failure still keeps it within the
 * success percentage requested.
 *
 * @param result {@code ITestResult} containing information about the run test
 * @see ITestResult#SUCCESS_PERCENTAGE_FAILURE
 */
@Override
public void onTestFailedButWithinSuccessPercentage(ITestResult result) {
    synchronized (testListeners) {
        for (ITestListener testListener : testListeners) {
            testListener.onTestFailedButWithinSuccessPercentage(result);
        }
    }
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:18,代码来源:ListenerChain.java


注:本文中的org.testng.ITestListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。