Package org.testng

Examples of org.testng.TestListenerAdapter


public class AlwaysRunTest extends SimpleBaseTest {

  @Test
  public void withAlwaysRunAfter() {
    TestListenerAdapter tla = new TestListenerAdapter();
    TestNG testng = create();
    testng.setOutputDirectory(OutputDirectoryPatch.getOutputDirectory());
    testng.setTestClasses(new Class[] { AlwaysRunAfter1.class });
    testng.addListener(tla);
    testng.run();
View Full Code Here


    assertTrue(AlwaysRunAfter1.success(), "afterTestMethod should have run");
  }

  @Test
  public void withoutAlwaysRunAfter() {
    TestListenerAdapter tla = new TestListenerAdapter();
    TestNG testng = create();
    testng.setOutputDirectory(OutputDirectoryPatch.getOutputDirectory());
    testng.setTestClasses(new Class[] { AlwaysRunAfter2.class });
    testng.addListener(tla);
    testng.run();
View Full Code Here

    assertTrue(AlwaysRunAfter2.success(), "afterTestMethod should not have run");
  }

  @Test
  public void withoutAlwaysRunBefore() {
    TestListenerAdapter tla = new TestListenerAdapter();
    TestNG testng = create();
    testng.setOutputDirectory(OutputDirectoryPatch.getOutputDirectory());
    testng.setTestClasses(new Class[] { AlwaysRunBefore1.class });
    testng.setGroups("A");
    testng.addListener(tla);
View Full Code Here

      t.getXmlClasses().add(c2);
    }

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

//    System.out.println(s.toXml());
    assertTestResultsEqual(tla.getPassedTests(), Arrays.asList("test1", "test2"));
  }
View Full Code Here

public class PolymorphicFailureTest extends SimpleBaseTest {

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

    assertTestResultsEqual(tla.getSkippedTests(), Arrays.asList(
        "polymorphicMethod",
        "executePolymorphicMethod")
        );
    Assert.assertEquals(0, tla.getPassedTests().size());
    Assert.assertEquals(0, tla.getFailedTests().size());
  }
View Full Code Here

    tng.setMaster(masterFile.getAbsolutePath());

    XmlSuite suite = createSuite("DistributedSuite1", new Class[] { Test1.class, Test2.class });
    tng.setXmlSuites(Arrays.asList(new XmlSuite[] { suite }));

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

    String[] passed = {
        "f1", "f2"
    };
    String[] failed = {};
    String[] skipped = {};

    verifyTests("Passed", passed, toMap(result.getPassedTests()));
    verifyTests("Failed", failed, toMap(result.getFailedTests()));
    verifyTests("Skipped", skipped, toMap(result.getSkippedTests()));

    return result;
  }
View Full Code Here

  }

  @Test
  public void twoHostsWithTestStrategy() throws IOException {
    startSlaves();
    TestListenerAdapter listener = twoHosts(SuiteDispatcher.STRATEGY_TEST);

    boolean found1 = false;
    boolean found2 = false;
    for (ITestResult tr : listener.getPassedTests()) {
      String host = tr.getHost();
      if (! found1) {
        found1 = host.contains(m_ports[0]);
      }
      if (! found2) {
View Full Code Here

      "-log", "0",
      "-d", OutputDirectoryPatch.getOutputDirectory(),
      "-junit",
      "-testclass", "test.sample.JUnitSample1"
    };
    TestListenerAdapter tla = new TestListenerAdapter();
    TestNG.privateMain(argv, tla);

    List<ITestResult> passed = tla.getPassedTests();
    assertEquals(passed.size(), 2);
    String test1 = passed.get(0).getMethod().getMethodName();
    String test2 = passed.get(1).getMethod().getMethodName();

    assertTrue(JUnitSample1.EXPECTED1.equals(test1) && JUnitSample1.EXPECTED2.equals(test2) ||
View Full Code Here

    String[] argv = {
      "-log", "0",
      "-d", OutputDirectoryPatch.getOutputDirectory(),
      "-testclass", "test.sample.JUnitSample1"
    };
    TestListenerAdapter tla = new TestListenerAdapter();
    TestNG.privateMain(argv, tla);

    List<ITestResult> passed = tla.getPassedTests();
    assertEquals(passed.size(), 0);
    }
View Full Code Here

      "-d", OutputDirectoryPatch.getOutputDirectory(),
      "-junit",
      "-testclass", "test.sample.JUnitSample1",
      "-suitename", "\""+suiteName+"\""
    };
    TestListenerAdapter tla = new TestListenerAdapter();
    TestNG.privateMain(argv, tla);

    List<ITestContext> contexts = tla.getTestContexts();
    assertTrue(contexts.size()>0);
    for (ITestContext context:contexts) {
      assertEquals(context.getSuite().getName(),suiteName);
    }
  }
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.