Package org.testng

Examples of org.testng.TestNG


public class CountTest extends SimpleBaseTest {

  @Test(description = "Make sure that skipped methods are accurately counted")
  public void skippedMethodsShouldBeCounted() {
    TestNG tng = create(CountSampleTest.class);

    IReporter r = new IReporter() {
      @Override
      public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites,
          String outputDirectory) {
        for (ISuite s : suites) {
          for (ISuiteResult sr : s.getResults().values()) {
            ITestContext ctx = sr.getTestContext();
            Assert.assertEquals(2, ctx.getSkippedTests().size());
          }
        }
      }
    };

    tng.addListener(r);
    tng.run();
  }
View Full Code Here


public class BeforeTestFailingTest extends SimpleBaseTest {

  @Test
  public void beforeTestFailingShouldCauseSkips() {
    TestNG tng = create(MyTestngTest2.class);
    TestListenerAdapter tla = new TestListenerAdapter();
    tng.addListener(tla);
    tng.run();

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

public class AbstractTest extends SimpleBaseTest {

  @Test(description = "Abstract methods defined in a superclass should be run")
  public void abstractShouldRun() {
    TestNG tng = create(CRUDTest2.class);
    TestListenerAdapter tla = new TestListenerAdapter();
    tng.addListener(tla);
    tng.run();

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

  private void runTest(XmlSuite suite) {
    final XmlTest test = createXmlTest(suite, "Simple Test", TestTestngCounter.class.getName());
    suite.setTests(Arrays.asList(test));

    final TestListenerAdapter tla = new TestListenerAdapter();
    final TestNG tng = create();
    tng.setXmlSuites(Arrays.asList(suite));
    tng.addListener(tla);
    tng.run();

    Assert.assertEquals(tla.getFailedTests().size(), 0);
    Assert.assertEquals(tla.getPassedTests().size(), 2);
  }
View Full Code Here

  @Test(description="Ensure that TestNG stops without running any tests if some class" +
      " included in suite is missing")
  public void handleInvalidSuites() {
     TestListenerAdapter tla = new TestListenerAdapter();
     try {
        TestNG tng = create();
        String testngXmlPath = getPathToResource("suite1.xml");
        tng.setTestSuites(Arrays.asList(testngXmlPath));
        tng.addListener(tla);
        tng.run();
     } catch (TestNGException ex) {
        Assert.assertEquals(tla.getPassedTests().size(), 0);
     }
  }
View Full Code Here

public class NestedStaticTest extends SimpleBaseTest {

  @Test
  public void nestedClassShouldBeIncluded() {
    TestNG tng = create(NestedStaticSampleTest.class);
    TestListenerAdapter tla = new TestListenerAdapter();
    tng.addListener(tla);
    tng.run();

    Set<String> expected = new HashSet<String>() {{
      add("nested");
      add("f");
    }};
View Full Code Here

      + "using SuiteResultCounts.calculateResultCounts(). This method has been throwing NPE "
      + "because it's unable to find SuiteRunner in HashMap, because the list of parameters in "
      + "SuiteRunner changed" + " during execution. This test makes sure we dont run into any NPEs")
  public void noNPEInCountingResults() {
    TestListenerAdapter tla = new TestListenerAdapter();
    TestNG tng = create();
    tng.setTestSuites(Arrays.asList(getPathToResource("param-inheritance/parent-suite.xml")));
    tng.setVerbose(2);
    tng.addListener(tla);
    OutputStream os = new ByteArrayOutputStream();
    PrintStream out = System.out;
    PrintStream err = System.err;
    try {
      /*
       * Changing system print streams so that exception or results stmt is not logged
       * while running test (avoid confusing person running tests)
       */
      System.setOut(new PrintStream(os));
      System.setErr(new PrintStream(os));
      tng.run();
      Assert.assertEquals(tla.getPassedTests().size(), 1);
    }
    finally {
      try {
        os.close();
View Full Code Here

  }

  @Test(description = "Checks to make sure parameters are inherited and overridden properly")
  public void parameterInheritanceAndOverriding() {
    TestListenerAdapter tla = new TestListenerAdapter();
    TestNG tng = create();
    tng.setUseDefaultListeners(false);
    tng.setTestSuites(Arrays.asList(getPathToResource("parametertest/parent-suite.xml")));
    tng.addListener(tla);
    tng.run();
    Assert.assertEquals(tla.getPassedTests().size(), 3);
  }
View Full Code Here

   * Child suites and tests within different suites have same names
   */
  @Test
  public void check() {
    TestListenerAdapter tla = new TestListenerAdapter();
    TestNG tng = create();
    String testngXmlPath = getPathToResource("checksuitesinitialization/parent-suite.xml");
    tng.setTestSuites(Arrays.asList(testngXmlPath));
    tng.addListener(tla);
    tng.run();
    Assert.assertEquals(tla.getPassedTests().size(), 4);
  }
View Full Code Here

public class TestNG173Test extends SimpleBaseTest {

  @Test
  public void orderShouldBePreservedInMethodsWithSameNameAndInDifferentClasses() {
    TestNG tng = create();
    XmlSuite s = createXmlSuite("PreserveOrder");
    XmlTest t = new XmlTest(s);

    t.getXmlClasses().add(new XmlClass("test.testng173.ClassA"));
    t.getXmlClasses().add(new XmlClass("test.testng173.ClassB"));

    t.setPreserveOrder("true");

    tng.setXmlSuites(Arrays.asList(s));

    TestListenerAdapter tla = new TestListenerAdapter();
    tng.addListener(tla);
    tng.run();

    // bug
    //verifyPassedTests(tla, "test1", "test2", "testX", "test1", "test2");

    // Proposed fix
View Full Code Here

TOP

Related Classes of org.testng.TestNG

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.