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


Java ITestNGListener类代码示例

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


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

示例1: processLinkedListeners

import org.testng.ITestNGListener; //导入依赖的package包/类
/**
 * Process the {@link LinkedListeners} annotation of the specified test class.
 * 
 * @param testClass test class
 */
private void processLinkedListeners(Class<?> testClass) {
    Objects.requireNonNull(testClass, "[testClass] must be non-null");
    
    LinkedListeners annotation = testClass.getAnnotation(LinkedListeners.class);
    if (null != annotation) {
        Class<?> markedClass = testClass;
        while (null == markedClass.getDeclaredAnnotation(LinkedListeners.class)) {
            markedClass = markedClass.getSuperclass();
        }
        if ( ! markedClasses.contains(markedClass)) {
            markedClasses.add(markedClass);
            for (Class<? extends ITestNGListener> listener : annotation.value()) {
                attachListener(listener, null);
            }
        }
    }
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:23,代码来源:ListenerChain.java

示例2: verifyHappyPath

import org.testng.ITestNGListener; //导入依赖的package包/类
@Test
public void verifyHappyPath() {
    
    ListenerChain lc = new ListenerChain();
    TestListenerAdapter tla = new TestListenerAdapter();
    
    TestNG testNG = new TestNG();
    testNG.setTestClasses(new Class[]{ArtifactCollectorTestCases.class});
    testNG.addListener((ITestNGListener) lc);
    testNG.addListener((ITestNGListener) tla);
    testNG.setGroups("testPassed");
    testNG.run();
    
    assertEquals(tla.getPassedTests().size(), 1, "Incorrect passed test count");
    assertEquals(tla.getFailedTests().size(), 0, "Incorrect failed test count");
    assertEquals(tla.getSkippedTests().size(), 0, "Incorrect skipped test count");
    assertEquals(tla.getFailedButWithinSuccessPercentageTests().size(), 0, "Incorrect curve-graded success count");
    assertEquals(tla.getConfigurationFailures().size(), 0, "Incorrect configuration method failure count");
    assertEquals(tla.getConfigurationSkips().size(), 0, "Incorrect configuration method skip count");
    
    ITestResult result = tla.getPassedTests().get(0);
    assertNull(UnitTestArtifact.getCaptureState(result), "Artifact provider capture state should be 'null'");
    assertNull(UnitTestCapture.getArtifactPath(result), "Artifact capture should not have been requested");
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:25,代码来源:ArtifactCollectorTest.java

示例3: verifyCaptureOnFailure

import org.testng.ITestNGListener; //导入依赖的package包/类
@Test
public void verifyCaptureOnFailure() {
    
    ListenerChain lc = new ListenerChain();
    TestListenerAdapter tla = new TestListenerAdapter();
    
    TestNG testNG = new TestNG();
    testNG.setTestClasses(new Class[]{ArtifactCollectorTestCases.class});
    testNG.addListener((ITestNGListener) lc);
    testNG.addListener((ITestNGListener) tla);
    testNG.setGroups("testFailed");
    testNG.run();
    
    assertEquals(tla.getPassedTests().size(), 0, "Incorrect passed test count");
    assertEquals(tla.getFailedTests().size(), 1, "Incorrect failed test count");
    assertEquals(tla.getSkippedTests().size(), 0, "Incorrect skipped test count");
    assertEquals(tla.getFailedButWithinSuccessPercentageTests().size(), 0, "Incorrect curve-graded success count");
    assertEquals(tla.getConfigurationFailures().size(), 0, "Incorrect configuration method failure count");
    assertEquals(tla.getConfigurationSkips().size(), 0, "Incorrect configuration method skip count");
    
    ITestResult result = tla.getFailedTests().get(0);
    assertEquals(UnitTestArtifact.getCaptureState(result), CaptureState.CAPTURE_SUCCESS, "Incorrect artifact provider capture state");
    assertTrue(UnitTestCapture.getArtifactPath(result).isPresent(), "Artifact capture output path is not present");
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:25,代码来源:ArtifactCollectorTest.java

示例4: verifyCanNotCapture

import org.testng.ITestNGListener; //导入依赖的package包/类
@Test
public void verifyCanNotCapture() {
    
    ListenerChain lc = new ListenerChain();
    TestListenerAdapter tla = new TestListenerAdapter();
    
    TestNG testNG = new TestNG();
    testNG.setTestClasses(new Class[]{ArtifactCollectorTestCases.class});
    testNG.addListener((ITestNGListener) lc);
    testNG.addListener((ITestNGListener) tla);
    testNG.setGroups("canNotCapture");
    testNG.run();
    
    assertEquals(tla.getPassedTests().size(), 0, "Incorrect passed test count");
    assertEquals(tla.getFailedTests().size(), 1, "Incorrect failed test count");
    assertEquals(tla.getSkippedTests().size(), 0, "Incorrect skipped test count");
    assertEquals(tla.getFailedButWithinSuccessPercentageTests().size(), 0, "Incorrect curve-graded success count");
    assertEquals(tla.getConfigurationFailures().size(), 0, "Incorrect configuration method failure count");
    assertEquals(tla.getConfigurationSkips().size(), 0, "Incorrect configuration method skip count");
    
    ITestResult result = tla.getFailedTests().get(0);
    assertEquals(UnitTestArtifact.getCaptureState(result), CaptureState.CAN_NOT_CAPTURE, "Incorrect artifact provider capture state");
    assertFalse(UnitTestCapture.getArtifactPath(result).isPresent(), "Artifact capture output path should not be present");
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:25,代码来源:ArtifactCollectorTest.java

示例5: verifyWillNotCapture

import org.testng.ITestNGListener; //导入依赖的package包/类
@Test
public void verifyWillNotCapture() {
    
    ListenerChain lc = new ListenerChain();
    TestListenerAdapter tla = new TestListenerAdapter();
    
    TestNG testNG = new TestNG();
    testNG.setTestClasses(new Class[]{ArtifactCollectorTestCases.class});
    testNG.addListener((ITestNGListener) lc);
    testNG.addListener((ITestNGListener) tla);
    testNG.setGroups("willNotCapture");
    testNG.run();
    
    assertEquals(tla.getPassedTests().size(), 0, "Incorrect passed test count");
    assertEquals(tla.getFailedTests().size(), 1, "Incorrect failed test count");
    assertEquals(tla.getSkippedTests().size(), 0, "Incorrect skipped test count");
    assertEquals(tla.getFailedButWithinSuccessPercentageTests().size(), 0, "Incorrect curve-graded success count");
    assertEquals(tla.getConfigurationFailures().size(), 0, "Incorrect configuration method failure count");
    assertEquals(tla.getConfigurationSkips().size(), 0, "Incorrect configuration method skip count");
    
    ITestResult result = tla.getFailedTests().get(0);
    assertEquals(UnitTestArtifact.getCaptureState(result), CaptureState.CAPTURE_FAILED, "Incorrect artifact provider capture state");
    assertFalse(UnitTestCapture.getArtifactPath(result).isPresent(), "Artifact capture output path should not be present");
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:25,代码来源:ArtifactCollectorTest.java

示例6: verifyOnDemandCapture

import org.testng.ITestNGListener; //导入依赖的package包/类
@Test
public void verifyOnDemandCapture() {
    
    ListenerChain lc = new ListenerChain();
    TestListenerAdapter tla = new TestListenerAdapter();
    
    TestNG testNG = new TestNG();
    testNG.setTestClasses(new Class[]{ArtifactCollectorTestCases.class});
    testNG.addListener((ITestNGListener) lc);
    testNG.addListener((ITestNGListener) tla);
    testNG.setGroups("onDemandCapture");
    testNG.run();
    
    assertEquals(tla.getPassedTests().size(), 1, "Incorrect passed test count");
    assertEquals(tla.getFailedTests().size(), 0, "Incorrect failed test count");
    assertEquals(tla.getSkippedTests().size(), 0, "Incorrect skipped test count");
    assertEquals(tla.getFailedButWithinSuccessPercentageTests().size(), 0, "Incorrect curve-graded success count");
    assertEquals(tla.getConfigurationFailures().size(), 0, "Incorrect configuration method failure count");
    assertEquals(tla.getConfigurationSkips().size(), 0, "Incorrect configuration method skip count");
    
    ITestResult result = tla.getPassedTests().get(0);
    assertEquals(UnitTestArtifact.getCaptureState(result), CaptureState.CAPTURE_SUCCESS, "Incorrect artifact provider capture state");
    assertTrue(UnitTestCapture.getArtifactPath(result).isPresent(), "Artifact capture output path is not present");
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:25,代码来源:ArtifactCollectorTest.java

示例7: testAttributeHandOff

import org.testng.ITestNGListener; //导入依赖的package包/类
@Test
public void testAttributeHandOff() {
    
    ExecutionFlowController efc = new ExecutionFlowController();
    TestListenerAdapter tla = new TestListenerAdapter();
    
    TestNG testNG = new TestNG();
    testNG.setTestClasses(new Class[]{HappyPathClass.class});
    testNG.addListener((ITestNGListener) efc);
    testNG.addListener((ITestNGListener) tla);
    testNG.run();
    
    assertEquals(tla.getFailedTests().size(), 0, "Unexpected test method failure");
    assertEquals(tla.getConfigurationFailures().size(), 0, "Unexpected configuration method failure");
    
    assertEquals(tla.getPassedTests().size(), 2, "Incorrect passed test count");
    assertEquals(tla.getFailedTests().size(), 0, "Incorrect failed test count");
    assertEquals(tla.getSkippedTests().size(), 0, "Incorrect skipped test count");
    
    assertEquals(HappyPathClass.fromBefore, HappyPathClass.VALUE, "Incorrect [before] value");
    assertEquals(HappyPathClass.fromMethod, HappyPathClass.VALUE, "Incorrect [method] value");
    assertEquals(HappyPathClass.fromAfter, HappyPathClass.VALUE, "Incorrect [after] value");
    
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:25,代码来源:ExecutionFlowControllerTest.java

示例8: testSkipFromMethod

import org.testng.ITestNGListener; //导入依赖的package包/类
@Test
public void testSkipFromMethod() {
    
    ExecutionFlowController efc = new ExecutionFlowController();
    TestListenerAdapter tla = new TestListenerAdapter();
    
    TestNG testNG = new TestNG();
    testNG.setTestClasses(new Class[]{SkipFromMethod.class});
    testNG.addListener((ITestNGListener) efc);
    testNG.addListener((ITestNGListener) tla);
    testNG.run();
    
    assertEquals(tla.getFailedTests().size(), 0, "Unexpected test method failure");
    assertEquals(tla.getConfigurationFailures().size(), 0, "Unexpected configuration method failure");
    
    assertEquals(tla.getPassedTests().size(), 1, "Incorrect passed test count");
    assertEquals(tla.getFailedTests().size(), 0, "Incorrect failed test count");
    assertEquals(tla.getSkippedTests().size(), 1, "Incorrect skipped test count");
    assertEquals(tla.getSkippedTests().get(0).getName(), "testMethod", "Incorrect skipped test name");
    
    assertEquals(SkipFromMethod.fromBefore, SkipFromMethod.VALUE, "Incorrect [before] value");
    assertEquals(SkipFromMethod.fromMethod, SkipFromMethod.VALUE, "Incorrect [method] value");
    assertEquals(SkipFromMethod.fromAfter, SkipFromMethod.VALUE, "Incorrect [after] value");
    
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:26,代码来源:ExecutionFlowControllerTest.java

示例9: isAnnotated

import org.testng.ITestNGListener; //导入依赖的package包/类
private boolean isAnnotated(Class<?> realClass)
{
    Listeners listeners = realClass.getAnnotation(Listeners.class);
    if (listeners == null)
    {
        return false;
    }
    for (Class<? extends ITestNGListener> listenerClass : listeners.value())
    {
        if (listenerClass.equals(MockitoTestNgListener.class))
        {
            return true;
        }
    }
    return false;
}
 
开发者ID:edgehosting,项目名称:jira-dvcs-connector,代码行数:17,代码来源:MockitoTestNgListener.java

示例10: getLinkedListener

import org.testng.ITestNGListener; //导入依赖的package包/类
/**
 * Get the listener of the specified type that's attached to the listener chain.
 * 
 * @param <T> listener type
 * @param listenerType listener type
 * @return listener of the specified type
 */
public static <T extends ITestNGListener> T getLinkedListener(Class<T> listenerType) {
    ITestResult testResult = Reporter.getCurrentTestResult();
    Optional<T> optListener = 
                    ListenerChain.getAttachedListener(testResult, listenerType);
    if (optListener.isPresent()) {
        return optListener.get();
    }
    throw new IllegalStateException(listenerType.getSimpleName() + " listener wasn't found on the listener chain");
}
 
开发者ID:Nordstrom,项目名称:Selenium-Foundation,代码行数:17,代码来源:TestNgBase.java

示例11: run

import org.testng.ITestNGListener; //导入依赖的package包/类
private InvokedMethodNameListener run(final String suitePath, final Supplier<BeforeMethodListener> listenerSupplier) {
    final TestNG tng = create();

    final InvokedMethodNameListener nameListener = new InvokedMethodNameListener();
    final BeforeMethodListener spyListener = listenerSupplier.get();

    tng.addListener((ITestNGListener) nameListener);
    tng.addListener((ITestNGListener) spyListener);
    tng.setTestSuites(singletonList(suitePath));
    tng.run();

    return nameListener;
}
 
开发者ID:sskorol,项目名称:webdriver-supplier,代码行数:14,代码来源:ListenerTests.java

示例12: with

import org.testng.ITestNGListener; //导入依赖的package包/类
/**
 * Constructs new {@link TestNGEngine} object with wanted listeners.
 *
 * @param listeners an instance (or instances) of engine's listeners
 * @return an instance of {@link TestNGEngine}
 */
@Override
public TestNGEngine with(ITestNGListener... listeners) {
    final TestNG testNG = new TestNG(false);
    Arrays.stream(listeners).forEach(testNG::addListener);
    return new TestNGEngine(testNG, this.tests);
}
 
开发者ID:tatools,项目名称:sunshine,代码行数:13,代码来源:TestNGEngine.java

示例13: with

import org.testng.ITestNGListener; //导入依赖的package包/类
/**
 * Constructs new {@link TestNGKernel} object with wanted listeners.
 *
 * @param listeners an instance (or instances) of engine's listeners
 * @return an instance of {@link TestNGKernel}
 */
@Override
public TestNGKernel with(ITestNGListener... listeners) {
    final TestNGKernel kernel = new TestNGKernel(this.suite);
    Arrays.stream(listeners).forEach(kernel.engine::addListener);
    return kernel;
}
 
开发者ID:tatools,项目名称:sunshine,代码行数:13,代码来源:TestNGKernel.java

示例14: prepare

import org.testng.ITestNGListener; //导入依赖的package包/类
@BeforeMethod(description = "Configure TestNG engine")
public void prepare() {
    results = new AllureResultsWriterStub();
    lifecycle = new AllureLifecycle(results);
    AllureTestNg adapter = new AllureTestNg(lifecycle);
    testNg = new TestNG(false);
    testNg.addListener((ITestNGListener) adapter);
}
 
开发者ID:allure-framework,项目名称:allure-java,代码行数:9,代码来源:AllureTestNgTest.java

示例15: getAttachedListener

import org.testng.ITestNGListener; //导入依赖的package包/类
/**
 * Get reference to an instance of the specified listener type.
 * 
 * @param <T> listener type
 * @param suite TestNG suite object
 * @param listenerType listener type
 * @return optional listener instance
 */
public static <T extends ITestNGListener> Optional<T>
        getAttachedListener(ISuite suite, Class<T> listenerType) {
    
    Objects.requireNonNull(suite, "[suite] must be non-null");
    Objects.requireNonNull(listenerType, "[listenerType] must be non-null");
    ListenerChain chain = (ListenerChain) suite.getAttribute(LISTENER_CHAIN);
    Objects.requireNonNull(chain, "Specified suite has no ListenerChain");
    return chain.getAttachedListener(listenerType);
}
 
开发者ID:Nordstrom,项目名称:TestNG-Foundation,代码行数:18,代码来源:ListenerChain.java


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