Package org.testng

Examples of org.testng.TestNG


      c2.getLocalParameters().put("a", "Second");
      c2.getIncludedMethods().add(include2);
      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


  }

  @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);
    testng.run();
    assertTrue(AlwaysRunBefore1.success(), "before alwaysRun methods should have been run");
  }
View Full Code Here

public class AfterMethodTest extends SimpleBaseTest {

  @Test
  public void testContextShouldBeInitialized() {
    TestNG tng = create(AfterMethodSampleTest.class);
    tng.run();
    Assert.assertTrue(AfterMethodSampleTest.m_success);
  }
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")
        );
View Full Code Here

  }

  private String[] m_ports = new String[2];

  public TestListenerAdapter twoHosts(String strategy) throws IOException {
    TestNG tng = new TestNG();
    tng.setOutputDirectory(OutputDirectoryPatch.getOutputDirectory());

    File masterFile = createMasterProperties(strategy);
    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 = {};
View Full Code Here

   * Make sure that without a transformer in place, a class-level
   * annotation invocationCount is correctly used.
   */
  @Test
  public void verifyAnnotationWithoutTransformer() {
    TestNG tng = new TestNG();
    tng.setVerbose(0);
    tng.setTestClasses(new Class[] { AnnotationTransformerClassInvocationSampleTest.class});
    TestListenerAdapter tla = new TestListenerAdapter();
    tng.addListener(tla);

    tng.run();

    List passed = tla.getPassedTests();
    Assert.assertEquals(passed.size(), 6);
  }
View Full Code Here

public class InjectTestResultTest extends SimpleBaseTest {

  @Test
  public void verifyTestResultInjection() {
    TestNG tng = create(InjectBeforeAndAfterMethodsWithTestResultSampleTest.class);
    tng.run();

    Assert.assertEquals(0, InjectBeforeAndAfterMethodsWithTestResultSampleTest.m_success);
  }
View Full Code Here

  /**
   * Test a transformer on a method-level @Test
   */
  @Test
  public void verifyAnnotationTransformerMethod() {
    TestNG tng = new TestNG();
    tng.setVerbose(0);
    tng.setAnnotationTransformer(new MyTransformer());
    tng.setTestClasses(new Class[] { AnnotationTransformerSampleTest.class});
    TestListenerAdapter tla = new TestListenerAdapter();
    tng.addListener(tla);

    tng.run();

    List passed = tla.getPassedTests();
    Assert.assertEquals(passed.size(), 15);
  }
View Full Code Here

  }

  private void runTest(IAnnotationTransformer transformer,
      String passedName, String failedName)
  {
    TestNG tng = new TestNG();
    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;
View Full Code Here

public class InjectAfterMethodWithTestResultTest extends SimpleBaseTest {

  @Test
  public void verifyTestResultInjection() {
    TestNG tng = create(InjectAfterMethodWithTestResultSampleTest.class);
    tng.run();

    Assert.assertEquals(0, InjectAfterMethodWithTestResultSampleTest.m_success);
  }
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.