Package org.testng

Examples of org.testng.TestListenerAdapter


        /*
         * Run a dummy test.
         */
        TestNG testNG = new TestNG();
        testNG.setTestClasses(new Class[]{DummyTest.class});
        TestListenerAdapter adapter = new TestListenerAdapter();
        testNG.addListener(adapter);
        testNG.run();
        // RHQ additional timing data
        Map<String, Long> timings = new HashMap<String, Long>();
        timings.put("test", 123L);


        /*
         * Set up the reporter
         */
        PerformanceReportExporter rep = new ExcelExporter();
        rep.setBaseFile("test1");
        rep.setRolling(PerformanceReporting.Rolling.NONE);


        /*
         * Write to .xls file twice
         */
        rep.export(timings,adapter.getPassedTests().iterator().next());
        rep.export(timings,adapter.getPassedTests().iterator().next());

        /*
         * Now check the workbook written
         * But first delete an existing file
         */
 
View Full Code Here


   public void shouldNotCallArquillianWhenNonArquillianClassIsRan() throws Exception
   {
      TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class);
      executeAllLifeCycles(adaptor);

      TestListenerAdapter result = run(adaptor, NonArquillianClass1.class);
      Assert.assertTrue(wasSuccessful(result));

      assertCycle(0, Cycle.values());
   }
View Full Code Here

   public void shouldNotCallArquillianWhenNonArquillianGroupIsRan() throws Exception
   {
      TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class);
      executeAllLifeCycles(adaptor);

      TestListenerAdapter result = run(new String[]{"non-arq"}, adaptor, NonArquillianClass1.class, ArquillianClass1.class);
      Assert.assertTrue(wasSuccessful(result));

      assertCycle(0, Cycle.values());
   }
View Full Code Here

   public void shouldCallArquillianWhenGroupIsRan() throws Exception
   {
      TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class);
      executeAllLifeCycles(adaptor);

      TestListenerAdapter result = run(new String[]{"arq"}, adaptor, NonArquillianClass1.class, ArquillianClass2.class);
      Assert.assertTrue(wasSuccessful(result));

      assertCycle(1, Cycle.values());
   }
View Full Code Here

   public void shouldCallArquillianWhenArquillianGroupIsActive() throws Exception
   {
      TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class);
      executeAllLifeCycles(adaptor);

      TestListenerAdapter result = run(new String[]{"arq", "arquillian"}, adaptor, NonArquillianClass1.class, ArquillianClass2.class);
      Assert.assertTrue(wasSuccessful(result));

      assertCycle(1, Cycle.values());
   }
View Full Code Here

   {
      try
      {
         setAdaptor(adaptor);

         TestListenerAdapter listener = new TestListenerAdapter();
         TestNG runner = new TestNG(false);
         runner.addListener(listener);
         runner.setXmlSuites(Arrays.asList(createSuite(groups, classes)));

         runner.run();
View Full Code Here

   public void shouldNotCallAnyMethodsWithoutLifecycleHandlers() throws Exception
   {
      TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class);
      when(adaptor.test(isA(TestMethodExecutor.class))).thenReturn(new TestResult(Status.PASSED));

      TestListenerAdapter result = run(adaptor, ArquillianClass1.class);

      Assert.assertTrue(wasSuccessful(result));
      assertCycle(0, Cycle.values());

      assertCycle(1, Cycle.BEFORE_SUITE, Cycle.AFTER_SUITE);
View Full Code Here

   public void shouldCallAllMethods() throws Exception
   {
      TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class);
      executeAllLifeCycles(adaptor);

      TestListenerAdapter result = run(adaptor, ArquillianClass1.class);

      Assert.assertTrue(wasSuccessful(result));
      assertCycle(1, Cycle.values());

      assertCycle(1, Cycle.BEFORE_SUITE, Cycle.AFTER_SUITE);
View Full Code Here

      TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class);
      executeAllLifeCycles(adaptor);

      throwException(Cycle.BEFORE_CLASS, new Throwable());

      TestListenerAdapter result = run(adaptor, ArquillianClass1.class);
      Assert.assertFalse(wasSuccessful(result));

      assertCycle(1, Cycle.BEFORE_CLASS, Cycle.AFTER_CLASS);
      assertCycle(0, Cycle.BEFORE, Cycle.AFTER, Cycle.TEST);
View Full Code Here

      TestRunnerAdaptor adaptor = mock(TestRunnerAdaptor.class);
      executeAllLifeCycles(adaptor);

      throwException(Cycle.BEFORE, new Throwable());

      TestListenerAdapter result = run(adaptor, ArquillianClass1.class);
      Assert.assertFalse(wasSuccessful(result));

      assertCycle(1, Cycle.BEFORE_CLASS, Cycle.AFTER_CLASS, Cycle.BEFORE, Cycle.AFTER);
      assertCycle(0, Cycle.TEST);
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.