Package org.jboss.arquillian.test.spi

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


        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: %s", executionType, testCanonicalName);
            if (executionType == ExecutionType.REMOTE) {
                result = testRunner.runTestMethodRemote(testClass, testMethod);
            } else {
                InputStream resultStream = testRunner.runTestMethodEmbedded(testClass, testMethod);
                ObjectInputStream ois = new ObjectInputStream(resultStream);
                result = (TestResult) ois.readObject();
            }
        } 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


      return runTestMethodInternal(className, methodName);
   }

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

      // Marshall the TestResult
      try
      {
         ByteArrayOutputStream baos = new ByteArrayOutputStream();
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

    public void onStopRecording(@Observes StopRecordVideo event) throws IOException {
        Video video = recorder.get().stopRecording();
        takenResourceRegister.get().addTaken(video);

        TestResult testResult = event.getVideoMetaData().getTestResult();

        if (testResult != null) {
            Status status = testResult.getStatus();
            appendStatus(video, status);
            if (!status.equals(Status.FAILED) && configuration.get().getTakeOnlyOnFail()) {
                if (!video.getResource().getAbsoluteFile().delete()) {
                    System.out.println("video was not deleted: " + video.getResource().getAbsolutePath());
                }
View Full Code Here

    public void propagateThrowableAsTestResultAndRethrow(@Observes Throwable throwable) throws Throwable {
        throwable.printStackTrace();

        if (responsePayload() != null) {
            storeFirstFailure(new TestResult(Status.FAILED, throwable));
        }

        // throwable must be rethrown, because Arquillian Core checks whether throwable was observed
        // and if yes, it does not let it bubble down the stack
        throw throwable;
View Full Code Here

        try {
            executeWarp.fire(new ExecuteWarp());

        } catch (Throwable e) {
            testResult.fire(new TestResult(Status.FAILED, e));
        }

        if (responsePayload.getTestResult() != null) {
            if (responsePayload.getTestResult().getThrowable() != null) {
                if (WarpCommons.debugMode()) {
                    log.log(Level.SEVERE, "exception was thrown during Warp execution", responsePayload.getTestResult().getThrowable());
                }
            }
        } else {
            responsePayload.setTestResult(new TestResult(Status.PASSED));
        }

        try {
            enrichHttpResponse.fire(new EnrichHttpResponse());
        } catch (Exception e) {
View Full Code Here

{
   @Test
   public void shouldReturnPassedTest() throws Exception
   {
      TestNGTestRunner runner = new TestNGTestRunner();
      TestResult result = runner.execute(ShouldProvideVariousTestResultsToTestRunner.class, "shouldProvidePassingTestToRunner");

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

   @Test
   public void shouldReturnFailedTest() throws Exception
   {
      TestNGTestRunner runner = new TestNGTestRunner();
      TestResult result = runner.execute(ShouldProvideVariousTestResultsToTestRunner.class, "shouldProvideFailingTestToRunner");

      Assert.assertNotNull(result);
      Assert.assertEquals(TestResult.Status.FAILED, result.getStatus());
      Assert.assertEquals(AssertionError.class, result.getThrowable().getClass());
   }
View Full Code Here

   @Test
   public void shouldReturnFailedTestAfterConfigurationError() throws Exception
   {
      TestNGTestRunner runner = new TestNGTestRunner();
      TestResult result = runner.execute(ShouldProvideConfigurationFailureToTestRunner.class, "successfulTest");

      Assert.assertNotNull(result);
      Assert.assertEquals(TestResult.Status.FAILED, result.getStatus());
      Assert.assertEquals(ClassNotFoundException.class, result.getThrowable().getClass());
   }
View Full Code Here

   @Test
   public void shouldReturnExceptionOnPassedTest() throws Exception
   {
      TestNGTestRunner runner = new TestNGTestRunner();
      TestResult result = runner.execute(ShouldProvideVariousTestResultsToTestRunner.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

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.