Пример #1
0
  @Override
  public String getLabel() {
    String name = getName();

    if (testCaseRunner != null) {
      name += " - [" + testCaseRunner.getStatus() + "]";
    }

    if (isDisabled()) return name + " (disabled)";
    else return name;
  }
Пример #2
0
 /**
  * Runs the specified TestCase
  *
  * @param testCase the testcase to run
  * @param context
  */
 protected void runTestCase(WsdlTestCase testCase) {
   try {
     log.info("Running TestCase [" + testCase.getName() + "]");
     WsdlTestCaseRunner runner = testCase.run(new StringToObjectMap(), false);
     log.info(
         "TestCase ["
             + testCase.getName()
             + "] finished with status ["
             + runner.getStatus()
             + "] in "
             + (runner.getTimeTaken())
             + "ms");
   } catch (Exception e) {
     e.printStackTrace();
   }
 }
Пример #3
0
  public TestStepResult run(TestCaseRunner testRunner, TestCaseRunContext testRunContext) {
    WsdlMessageExchangeTestStepResult result = new WsdlMessageExchangeTestStepResult(this);

    testCaseRunner = null;

    if (targetTestCase != null) {
      Enum runMode = getRunMode();

      if (runMode == RunTestCaseRunModeTypeConfig.PARALLELL) {
        runningTestCase = createTestCase(targetTestCase);
      } else {
        runningTestCase = targetTestCase;

        TestCaseRunner targetTestRunner = SoapUI.getTestMonitor().getTestRunner(targetTestCase);
        if (targetTestRunner != null && targetTestRunner.getStatus() == TestRunner.Status.RUNNING) {
          if (runMode == RunTestCaseRunModeTypeConfig.SINGLETON_AND_FAIL) {
            result.setStatus(TestStepStatus.FAILED);
            result.addMessage("Target TestCase is already running");
            result.stopTimer();
            runningTestCase = null;
          } else {
            targetTestRunner.waitUntilFinished();
          }
        }
      }

      if (runningTestCase != null) {
        synchronized (runningTestCase) {
          for (TestRunListener listener : testRunListeners)
            runningTestCase.addTestRunListener(listener);

          StringList returnProperties = getReturnProperties();
          Map<String, TestProperty> props = getProperties();
          for (String key : props.keySet()) {
            if (runningTestCase.hasProperty(key) && !returnProperties.contains(key)) {
              String value = props.get(key).getValue();
              runningTestCase.setPropertyValue(
                  key, PropertyExpander.expandProperties(testRunContext, value));
            }
          }

          currentLabel = getLabel();
          runningTestCase.addTestRunListener(testRunListener);

          // StringToObjectMap properties = new StringToObjectMap();
          // for( String name : testRunContext.getPropertyNames() )
          // properties.put( name, testRunContext.getProperty( name ));

          result.startTimer();
          testCaseRunner = runningTestCase.run(new StringToObjectMap(), true);
          testCaseRunner.waitUntilFinished();
          result.stopTimer();

          for (String key : returnProperties) {
            if (runningTestCase.hasProperty(key))
              setPropertyValue(key, runningTestCase.getPropertyValue(key));
          }

          // aggregate results
          for (TestStepResult testStepResult : testCaseRunner.getResults()) {
            result.addMessage(
                testStepResult.getTestStep().getName()
                    + " - "
                    + testStepResult.getStatus()
                    + " - "
                    + testStepResult.getTimeTaken());
            for (String msg : testStepResult.getMessages()) {
              result.addMessage("- " + msg);
            }

            if (testStepResult instanceof MessageExchangeTestStepResult) {
              result.addMessages(
                  ((MessageExchangeTestStepResult) testStepResult).getMessageExchanges());
            }
          }

          switch (testCaseRunner.getStatus()) {
            case CANCELED:
              result.setStatus(TestStepStatus.CANCELED);
              break;
            case FAILED:
              result.setStatus(TestStepStatus.FAILED);
              break;
            case FINISHED:
              result.setStatus(TestStepStatus.OK);
              break;
            default:
              result.setStatus(TestStepStatus.UNKNOWN);
              break;
          }

          for (TestRunListener listener : testRunListeners)
            runningTestCase.removeTestRunListener(listener);

          if (runMode == RunTestCaseRunModeTypeConfig.PARALLELL) runningTestCase.release();

          runningTestCase = null;
          testCaseRunner = null;
        }
      }
    } else {
      result.setStatus(TestStepStatus.FAILED);
      result.addMessage("Missing testCase in project");
      result.stopTimer();
    }

    return result;
  }