Package org.testng

Examples of org.testng.TestNG.addListener()


  @Test(enabled = false)
  public void verifyTestContextInjection(ITestContext tc, XmlTest xmlTest) {
    TestNG tng = create();
    tng.setTestClasses(new Class[] { Sample.class });
    TestListenerAdapter tla = new TestListenerAdapter();
    tng.addListener(tla);
    tng.run();

    Assert.assertEquals(xmlTest.getName(), "Injection");
    Assert.assertEquals(tla.getPassedTests().size(), 1);
    Assert.assertEquals(tla.getPassedTests().get(0).getMethod().getMethodName(), "f");
View Full Code Here


public class FailingDataProviderTest extends SimpleBaseTest {
  private void shouldSkipOne(Class cls, String message) {
    TestNG testng = create(cls);
    TestListenerAdapter tla = new TestListenerAdapter();
    testng.addListener(tla);
    testng.run();
    Assert.assertEquals(tla.getSkippedTests().size(), 1, message);
  }

  @Test(description = "TESTNG-142: Exceptions in DataProvider are not reported as failed test")
View Full Code Here

    XmlTest t = createXmlTest(s, "Groups-test", GroupSuiteSampleTest.class.getName());
    t.setIncludedGroups(Arrays.asList(testGroups));
    t.setExcludedGroups(Arrays.asList(excludedTestGroups));
    TestListenerAdapter tla = new TestListenerAdapter();
    TestNG tng = create();
    tng.addListener(tla);
    tng.setXmlSuites(Arrays.asList(new XmlSuite[] { s }));
    tng.run();

    verifyPassedTests(tla, methods);
  }
View Full Code Here

    suite.setMethodSelectors(methodSelectors);
    XmlTest test = new XmlTest(suite);
    XmlClass testClass = new XmlClass(test.methodselectors.SampleTest.class);
    test.setXmlClasses(Arrays.asList(testClass));
    tng.setXmlSuites(Arrays.asList(suite));
    tng.addListener(m_tla);
    tng.run();

    validate(new String[] { "test2" });
  }
View Full Code Here

  @Test
  public void xmlXmlSuite() {
    TestNG tng = create();
    tng.setTestSuites(Arrays.asList(getPathToResource("methodselector-in-xml.xml")));
    tng.addListener(m_tla);
    tng.run();

    validate(new String[] { "test2" });
  }
View Full Code Here

    TestNG tng = create();
    if (group != null) tng.setGroups(group);
    if (excludedGroups != null) tng.setExcludedGroups(excludedGroups);
    tng.setXmlSuites(Arrays.asList(new XmlSuite[] { s }));
    TestListenerAdapter tla = new TestListenerAdapter();
    tng.addListener(tla);
    tng.run();

    assertTestResultsEqual(tla.getPassedTests(), methods);
  }
}
View Full Code Here

    TestNG testng = new TestNG();
    testng.setVerbose(0);
    testng.setSkipFailedInvocationCounts(skip);
    testng.setTestClasses(new Class[] { FailedInvocationCount.class });
    TestListenerAdapter tla = new TestListenerAdapter();
    testng.addListener(tla);
    testng.run();

    Assert.assertEquals(tla.getPassedTests().size(), passed);
    Assert.assertEquals(tla.getFailedTests().size(), failed);
    Assert.assertEquals(tla.getSkippedTests().size(), skipped);
View Full Code Here

  public void verifyAttributeShouldStop() {
    TestNG testng = new TestNG();
    testng.setVerbose(0);
    testng.setTestClasses(new Class[] { FailedInvocationCount2.class });
    TestListenerAdapter tla = new TestListenerAdapter();
    testng.addListener(tla);
    testng.run();

    Assert.assertEquals(tla.getPassedTests().size(), 8);
    Assert.assertEquals(tla.getFailedTests().size(), 7);
    Assert.assertEquals(tla.getSkippedTests().size(), 5);
View Full Code Here

        + "  </test>"
        + "</suite>"
        );
    TestNG tng = create();
    TestListenerAdapter tla = new TestListenerAdapter();
    tng.addListener(tla);
    if (include != null) tng.setGroups(include);
    if (exclude != null) tng.setExcludedGroups(exclude);
    tng.setTestSuites(Arrays.asList(f.getAbsolutePath()));
    tng.run();
View Full Code Here

    TestNG tng = new TestNG();
    tng.setVerbose(0);
    tng.setTestClasses(new Class[] { PrioritySampleTest.class });
    tng.addMethodSelector("test.methodselectors.NoTestSelector", priority);
    TestListenerAdapter tla = new TestListenerAdapter();
    tng.addListener(tla);
    tng.run();

    List<ITestResult> passed = tla.getPassedTests();
    Assert.assertEquals(passedTests.length, passed.size());
    if (passedTests.length == 1) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.