Package org.jboss.arquillian.spi

Examples of org.jboss.arquillian.spi.TestResult


      return runTestMethodInternal(className, methodName);
   }

   public InputStream runTestMethodRemote(String className, String methodName)
   {
      TestResult result = runTestMethodInternal(className, methodName);

      // Marshall the TestResult
      try
      {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here


      try
      {
         TestRunner runner = TestRunners.getTestRunner(JMXTestRunner.class.getClassLoader());
         Class<?> testClass = testClassLoader.loadTestClass(className);
        
         TestResult testResult = runner.execute(testClass, methodName);
         return testResult;
      }
      catch (Throwable th)
      {
         return new TestResult(Status.FAILED, th);
      }
   }
View Full Code Here

         {
            comparePerformanceSuiteResults(suiteResult, event.getTestMethod().getName());
         }
         catch (PerformanceException pe)
         {
            TestResult result = testResultInst.get();
            if (result != null)
            {
               result.setThrowable(pe);
            }
         }
      }
   }
View Full Code Here

{
   @Test
   public void shouldReturnPassedTest() throws Exception
   {
      TestNGTestRunner runner = new TestNGTestRunner();
      TestResult result = runner.execute(TestNGTestRunnerTestCase.class, "shouldProvidePassingTestToRunner");
     
      Assert.assertNotNull(result);
      Assert.assertEquals(TestResult.Status.PASSED, result.getStatus());
      Assert.assertNull(result.getThrowable());
   }
View Full Code Here

   @Test
   public void shouldReturnExceptionOnPassedTest() throws Exception
   {
      TestNGTestRunner runner = new TestNGTestRunner();
      TestResult result = runner.execute(TestNGTestRunnerTestCase.class, "shouldProvideExpectedExceptionToRunner");
     
      Assert.assertNotNull(result);
      Assert.assertEquals(TestResult.Status.PASSED, result.getStatus());
      Assert.assertNotNull(result.getThrowable());
      Assert.assertEquals(IllegalArgumentException.class, result.getThrowable().getClass());
   }
View Full Code Here

   @Inject
   private Instance<PerformanceSuiteResult> suiteResultInst;
  
   public void callback(@Observes Test event) throws Exception
   {
      TestResult result = testResultInst.get();
      if(result != null)
      {
         //check if we have set a threshold
         Performance performance = null;
         Annotation[] annotations =  event.getTestMethod().getDeclaredAnnotations();
         for(Annotation a : annotations)
            if(a.annotationType().getName().equals(Performance.class.getCanonicalName()))
               performance = (Performance) a;
       
         if(performance != null)
         {
            if(performance.time() > 0 &&
               performance.time() < (result.getEnd()-result.getStart()))
            {
               result.setStatus(Status.FAILED);
               result.setThrowable(
                     new PerformanceException("The test didnt finish within the specified time: "
                           +performance.time()+"ms, it took "+(result.getEnd()-result.getStart())+"ms."));
            }
           
            // fetch suiteResult, get the correct classResult and append the test to that
            // classResult.
            PerformanceSuiteResult suiteResult = suiteResultInst.get();
            if(suiteResult != null)
               suiteResult.getResult(event.getTestClass().getName()).addMethodResult(
                     new PerformanceMethodResult(
                           performance.time(),
                           (result.getEnd()-result.getStart()),
                           event.getTestMethod()));
            else
               System.out.println("PerformanceVerifier didnt get PerformanceSuiteResult!");
         }
      }
View Full Code Here

   /* (non-Javadoc)
    * @see org.jboss.arquillian.spi.ContainerMethodExecutor#invoke(org.jboss.arquillian.spi.TestMethodExecutor)
    */
   public TestResult invoke(TestMethodExecutor testMethodExecutor)
   {
      TestResult result = new TestResult();
      try
      {
         testMethodExecutor.invoke();
         result.setStatus(Status.PASSED);
      }
      catch (final Throwable e)
      {
         /*
          *  TODO: the internal state TestResult is FAILED with Exception set, but it might have passed
          *  due to the TestFrameworks ExpectedExceptions. We need to know this information to set the correct state.
          */

         result.setStatus(Status.FAILED);
         result.setThrowable(e);
      }
      finally
      {
         result.setEnd(System.currentTimeMillis());
      }
      return result;
   }
View Full Code Here

      deployableTest.get().after(this, testMethod, LifecycleMethodExecutor.NO_OP);
   }

   public void run(final IHookCallBack callback, final ITestResult testResult)
   {
      TestResult result;
      try
      {
         result = deployableTest.get().test(new TestMethodExecutor()
         {
            public void invoke(Object... parameters) throws Throwable
            {
               /*
                *  The parameters are stored in the InvocationHandler, so we can't set them on the test result directly.
                *  Copy the Arquillian found parameters to the InvocationHandlers parameters
                */
               copyParameters(parameters, callback.getParameters());
               callback.runTestMethod(testResult);
              
               // Parameters can be contextual, so extract information
               swapWithClassNames(callback.getParameters());
               testResult.setParameters(callback.getParameters());
            }
           
            private void copyParameters(Object[] source, Object[] target)
            {
               for(int i = 0; i < source.length; i++)
               {
                  target[i] = source[i];
               }
            }
           
            private void swapWithClassNames(Object[] source)
            {
               // clear parameters. they can be contextual and might fail TestNG during the report writing.
               for(int i = 0; source != null && i < source.length; i++)
               {
                  Object parameter = source[i];
                  if(parameter != null)
                  {
                     source[i] = parameter.toString();
                  }
                  else
                  {
                     source[i] = "null";
                  }
               }
            }
           
            public Method getMethod()
            {
               return testResult.getMethod().getMethod();
            }
           
            public Object getInstance()
            {
               return Arquillian.this;
            }
         });
         if(result.getThrowable() != null)
         {
            testResult.setThrowable(result.getThrowable());
         }

         // calculate test end time. this is overwritten in the testng invoker..
         testResult.setEndMillis( (result.getStart() - result.getEnd()) + testResult.getStartMillis());
      }
      catch (Exception e)
      {
         testResult.setThrowable(e);
      }
View Full Code Here

   public TestResult getTestResult()
   {
      if(context.getFailedTests().size() > 0)
      {
         return new TestResult(
               Status.FAILED,
               context.getFailedTests().getAllResults().iterator().next().getThrowable());
      }
      else if(context.getSkippedTests().size() > 0)
      {
         return new TestResult(Status.SKIPPED);
      }
      if(context.getPassedTests().size() > 0)
      {
         return new TestResult(
               Status.PASSED,
               context.getPassedTests().getAllResults().iterator().next().getThrowable());
      }
      return new TestResult(
            Status.FAILED,
            new RuntimeException("Unknown test result: " + context).fillInStackTrace());
   }
View Full Code Here

      deployableTest.get().after(this, testMethod);
   }

   public void run(final IHookCallBack callback, final ITestResult testResult)
   {
      TestResult result;
      try
      {
         result = deployableTest.get().test(new TestMethodExecutor()
         {
            public void invoke() throws Throwable
            {
               callback.runTestMethod(testResult);
              
               clearParameters(testResult);
            }

            private void clearParameters(final ITestResult testResult)
            {
               // clear parameters. they can be contextual and might fail TestNG during the report writing.
               Object[] parameters = testResult.getParameters();
               for(int i = 0; parameters != null && i < parameters.length; i++)
               {
                  Object parameter = parameters[i];
                  if(parameter != null)
                  {
                     parameters[i] = parameter.getClass().getName();
                  }
                  else
                  {
                     parameters[i] = "null";
                  }
               }
            }
           
            public Method getMethod()
            {
               return testResult.getMethod().getMethod();
            }
           
            public Object getInstance()
            {
               return Arquillian.this;
            }
         });
         if(result.getThrowable() != null)
         {
            testResult.setThrowable(result.getThrowable());
         }

         // calculate test end time. this is overwritten in the testng invoker..
         testResult.setEndMillis( (result.getStart() - result.getEnd()) + testResult.getStartMillis());
      }
      catch (Exception e)
      {
         testResult.setThrowable(e);
      }
View Full Code Here

TOP

Related Classes of org.jboss.arquillian.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.