當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。