Package org.jboss.arquillian.test.spi

Examples of org.jboss.arquillian.test.spi.TestResult


   @Test
   // TODO: this should me moved to new TestNG test suite
   public void shouldBeAbleToUseOtherDataProviders() throws Exception
   {
      TestNGTestRunner runner = new TestNGTestRunner();
      TestResult result = runner.execute(ShouldProvideVariousTestResultsToTestRunner.class, "shouldBeAbleToUseOtherDataProviders");

      Assert.assertNotNull(result);
      Assert.assertEquals(TestResult.Status.PASSED, result.getStatus());
      Assert.assertNull(result.getThrowable());
   }
View Full Code Here


      return Collections.emptyList();
   }

   public TestResult execute(Class<?> testClass, String methodName)
   {
      TestResult testResult = TestResult.passed(); // = new TestResult(Status.PASSED);
      ExpectedExceptionHolder exceptionHolder = new ExpectedExceptionHolder();
      try
      {
          JUnitCore runner = new JUnitCore();

          runner.addListener(exceptionHolder);

          for (RunListener listener : getRunListeners())
             runner.addListener(listener);

          Result result = runner.run(Request.method(testClass, methodName));

          if (result.getFailureCount() > 0)
          {
             testResult = TestResult.failed(exceptionHolder.getException());
          }
          else if (result.getIgnoreCount() > 0)
          {
              testResult = TestResult.skipped(null); // Will this ever happen incontainer?
          }
          else {
              testResult = TestResult.passed();
          }
          if(testResult.getThrowable() == null) {
              testResult.setThrowable(exceptionHolder.getException());
          }
      }
      catch (Throwable th) {
          testResult = TestResult.failed(th);
      }
      if(testResult.getThrowable() instanceof AssumptionViolatedException) {
          testResult = TestResult.skipped(testResult.getThrowable());
      }
      testResult.setEnd(System.currentTimeMillis());
      return testResult;
   }
View Full Code Here

         spockRunner.filter(new SpockSpecificationFilter(spockRunner, methodName));
         runTest(spockRunner, testResult);
      }
      catch (Exception e)
      {
         return new TestResult(Status.FAILED, e);
      }

      return convertToTestResult(testResult);
   }
View Full Code Here

      if (result.getIgnoreCount() > 0)
      {
         status = Status.SKIPPED;
      }

      return new TestResult(status, throwable);
   }
View Full Code Here

      doAnswer(new ExecuteLifecycle(Cycle.AFTER_SUITE)).when(adaptor).afterSuite();
      doAnswer(new ExecuteLifecycle(Cycle.BEFORE_CLASS)).when(adaptor).beforeClass(any(Class.class), any(LifecycleMethodExecutor.class));
      doAnswer(new ExecuteLifecycle(Cycle.AFTER_CLASS)).when(adaptor).afterClass(any(Class.class), any(LifecycleMethodExecutor.class));
      doAnswer(new ExecuteLifecycle(Cycle.BEFORE)).when(adaptor).before(any(Object.class), any(Method.class), any(LifecycleMethodExecutor.class));
      doAnswer(new ExecuteLifecycle(Cycle.AFTER)).when(adaptor).after(any(Object.class), any(Method.class), any(LifecycleMethodExecutor.class));
      doAnswer(new TestExecuteLifecycle(new TestResult(Status.PASSED))).when(adaptor).test(any(TestMethodExecutor.class));
   }
View Full Code Here

{
   @Test @Ignore("ARQ-582")
   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());
View Full Code Here

        String testMethod = testMethodExecutor.getMethod().getName();
        String testCanonicalName = testClass + "." + testMethod;

        NotificationListener commandListener = null;
        ObjectName objectName = null;
        TestResult result = null;
        try {
            objectName = new ObjectName(JMXTestRunnerMBean.OBJECT_NAME);
            commandListener = new CallbackNotificationListener(objectName);
            mbeanServer.addNotificationListener(objectName, commandListener, null, null);

            JMXTestRunnerMBean testRunner = getMBeanProxy(objectName, JMXTestRunnerMBean.class);
            log.debugf("Invoke %s", testCanonicalName);
            result = Serializer.toObject(TestResult.class, testRunner.runTestMethod(testClass, testMethod));

        } catch (final Throwable th) {
            result = new TestResult(Status.FAILED);
            result.setThrowable(th);
        } finally {
            result.setEnd(System.currentTimeMillis());
            if (objectName != null && commandListener != null) {
                try {
                    mbeanServer.removeNotificationListener(objectName, commandListener);
                } catch (Throwable th) {
                    log.errorf(th, "Cannot remove notification listener");
                }
            }
        }
        log.debugf("Result: %s", result);
        if (result.getStatus() == Status.FAILED)
            log.errorf(result.getThrowable(), "Failed: %s", testCanonicalName);
        return result;
    }
View Full Code Here

      localMBeanServer = null;
   }

   public byte[] runTestMethod(String className, String methodName)
   {
      TestResult result = runTestMethodInternal(className, methodName);
      return Serializer.toByteArray(result);
   }
View Full Code Here

   }

   private TestResult runTestMethodInternal(String className, String methodName)
   {
      currentCall.set(className + methodName);
      TestResult result = new TestResult();
      try
      {
         TestRunner runner = mockTestRunner;
         if (runner == null)
         {
            runner = TestRunners.getTestRunner(getClass().getClassLoader());
         }

         log.debugf("Load test class: %s", className);
         Class<?> testClass = testClassLoader.loadTestClass(className);
         log.debugf("Test class loaded from: %s", testClass.getClassLoader());

         log.debugf("Execute: %s.%s", testClass, methodName);
         result = runner.execute(testClass, methodName);
      }
      catch (Throwable th)
      {
         result.setStatus(Status.FAILED);
         result.setEnd(System.currentTimeMillis());
         result.setThrowable(th);
      }
      finally
      {
         log.debugf("Result: %s", result);
         if (result.getStatus() == Status.FAILED)
            log.errorf(result.getThrowable(), "Failed: %s.%s", className, methodName);
      }
      return result;
   }
View Full Code Here

      localMBeanServer = null;
   }

   public byte[] runTestMethod(String className, String methodName)
   {
      TestResult result = runTestMethodInternal(className, methodName);
      return Serializer.toByteArray(result);
   }
View Full Code Here

TOP

Related Classes of org.jboss.arquillian.test.spi.TestResult

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.