Package org.testng

Examples of org.testng.TestListenerAdapter


    tng.setVerbose(0);
    if (transformer != null) {
      tng.setAnnotationTransformer(transformer);
    }
    tng.setTestClasses(new Class[] { AnnotationTransformerClassSampleTest.class});
    TestListenerAdapter tla = new TestListenerAdapter();
    tng.addListener(tla);

    tng.run();

    List<ITestResult> results =
      passedName != null ? tla.getPassedTests() : tla.getFailedTests();
    String name = passedName != null ? passedName : failedName;

    Assert.assertEquals(results.size(), 1);
    Assert.assertEquals(name, results.get(0).getMethod().getMethodName());
  }
View Full Code Here


  public void verifyConfigurationTransformer() {
    TestNG tng = new TestNG();
    tng.setAnnotationTransformer(new ConfigurationTransformer());
    tng.setVerbose(0);
    tng.setTestClasses(new Class[] { ConfigurationSampleTest.class});
    TestListenerAdapter tla = new TestListenerAdapter();
    tng.addListener(tla);

    tng.run();

    Assert.assertEquals(ConfigurationSampleTest.getBefore(), "correct");
View Full Code Here

  @Test
  public void verifyDataProviderTransformer() {
    TestNG tng = create();
    tng.setAnnotationTransformer(new DataProviderTransformer());
    tng.setTestClasses(new Class[] { AnnotationTransformerDataProviderSampleTest.class});
    TestListenerAdapter tla = new TestListenerAdapter();
    tng.addListener(tla);

    tng.run();

    Assert.assertEquals(tla.getPassedTests().size(), 1);
  }
View Full Code Here

  @Test
  public void verifyFactoryTransformer() {
    TestNG tng = create();
    tng.setAnnotationTransformer(new FactoryTransformer());
    tng.setTestClasses(new Class[] { AnnotationTransformerFactorySampleTest.class});
    TestListenerAdapter tla = new TestListenerAdapter();
    tng.addListener(tla);

    tng.run();

    Assert.assertEquals(tla.getPassedTests().size(), 1);
  }
View Full Code Here

    ByteArrayInputStream is = new ByteArrayInputStream(xml.getBytes());
    Collection<XmlSuite> suites = new Parser(is).parse();

    TestNG tng = create();
    tng.setXmlSuites(Arrays.asList(suites.toArray(new XmlSuite[0])));
    TestListenerAdapter tla = new TestListenerAdapter();
    tng.addListener(tla);

    tng.run();

    Assert.assertEquals(tla.getPassedTests().size(), 1);

  }
View Full Code Here

* This class/interface
*/
public class SkippedExceptionTest {
  @Test
  public void skippedExceptionInConfigurationMethods() {
    TestListenerAdapter listener= new TestListenerAdapter();
    TestNG test= new TestNG(false);
    test.addListener(listener);
    test.setVerbose(0);
    test.setTestClasses(new Class[] {ConfigurationSkippedExceptionTest.class});
    test.run();
    List<ITestResult> confSkips= listener.getConfigurationSkips();
    List<ITestResult> testSkips= listener.getSkippedTests();
    Assert.assertEquals(testSkips.size(), 1);
    Assert.assertEquals(testSkips.get(0).getMethod().getMethodName(), "dummyTest");

    Assert.assertEquals(confSkips.size(), 1);
    Assert.assertEquals(confSkips.get(0).getMethod().getMethodName(), "configurationLevelSkipException");
View Full Code Here

  }


  @Test
  public void skippedExceptionInTestMethods() {
    TestListenerAdapter listener= new TestListenerAdapter();
    TestNG test= new TestNG(false);
    test.addListener(listener);
    test.setVerbose(0);
    test.setTestClasses(new Class[] {TestSkippedExceptionTest.class});
    test.run();
    List<ITestResult> skips= listener.getSkippedTests();
    List<ITestResult> failures= listener.getFailedTests();
    Assert.assertEquals(skips.size(), 1);
    Assert.assertEquals(failures.size(), 1);
    Assert.assertEquals(skips.get(0).getMethod().getMethodName(), "genericSkipException");
    Assert.assertEquals(failures.get(0).getMethod().getMethodName(), "timedSkipException");
  }
View Full Code Here

    String path = currentDir.getAbsolutePath();
    char s = File.separatorChar;
    path = path + s + "test" + s + "src" + s + "test" + s + "jarpackages" + s;
    String finalPath = path + jarFile;
    tng.setTestJar(finalPath);
    TestListenerAdapter result = new TestListenerAdapter();
    tng.addListener(result);
    tng.run();

    return result;
  }
View Full Code Here

    return result;
  }

  @Test
  public void jarWithTestngXml() {
    TestListenerAdapter tla = init("withtestngxml.jar");
    Assert.assertEquals(tla.getPassedTests().size(), 2);
    String first = tla.getPassedTests().get(0).getName();
    String second = tla.getPassedTests().get(1).getName();
    boolean fThenG = "f".equals(first) && "g".equals(second);
    boolean gThenF = "g".equals(first) && "f".equals(second);
    Assert.assertTrue(fThenG || gThenF);
  }
View Full Code Here

    Assert.assertTrue(fThenG || gThenF);
  }

  @Test
  public void jarWithoutTestngXml() {
    TestListenerAdapter tla = init("withouttestngxml.jar");
    Assert.assertEquals(tla.getPassedTests().size(), 2);
    String first = tla.getPassedTests().get(0).getName();
    String second = tla.getPassedTests().get(1).getName();
    boolean fThenG = "f".equals(first) && "g".equals(second);
    boolean gThenF = "g".equals(first) && "f".equals(second);
    Assert.assertTrue(fThenG || gThenF);
  }
View Full Code Here

TOP

Related Classes of org.testng.TestListenerAdapter

Copyright © 2018 www.massapicom. 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.