示例#1
0
 private void setJMeterPropertyFile(JMeterTest jMeterTest) throws IOException {
   if (jMeterTest.getJMeterPropertyFile() == null) {
     log.info("Loading default jmeter.properties...");
     jmeterProps = JMeterInstallationProvider.getInstance().getJMeterPropertyFile();
     System.setProperty(
         "jmeter_properties", File.separator + "bin" + File.separator + "jmeter.properties");
   } else {
     log.info(
         "Loading custom jmeter.properties from "
             + jMeterTest.getJMeterPropertyFile().getCanonicalPath());
     jmeterProps = jMeterTest.getJMeterPropertyFile();
     System.setProperty("jmeter_properties", jmeterProps.getCanonicalPath());
   }
 }
示例#2
0
  public void runTest(JMeterTest jMeterTest) throws Exception {
    JMeterResult results;

    // Init JMeter
    jmeterHome = JMeterInstallationProvider.getInstance().getJMeterHome();

    testFile = jMeterTest.getTestFile();
    // setting jmeter.properties file parameter
    setJMeterPropertyFile(jMeterTest);

    if (jMeterTest.getLogLevel() != null) {
      jmeterLogLevel = jMeterTest.getLogLevel();
    }

    results = executeMe();
    //        checkForErrors();
    log.info("for more info. " + results.getFileName());
    if (results.getErrorCount() > 0) {
      throw new Exception(
          "Test Failed. "
              + results.getErrorCount()
              + " Error/s Found.\n"
              + results.getErrorList().toString()
              + "\nRefer "
              + results.getFileName()
              + " for test result");
    }

    if (results.getFailureCount() > 0) {
      throw new AssertionError(
          "Test Failed. "
              + results.getFailureCount()
              + " Assertion Failure/s.\n"
              + results.getAssertList().toString()
              + "\nRefer "
              + results.getFileName()
              + " for test result");
    }
  }