Surok112 / robotframework-maven-plugin

Automatically exported from code.google.com/p/robotframework-maven-plugin
0 stars 0 forks source link

retry on the failed testsuites #27

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
In our usage of framework on the UI testing, a lot of time we need to retry the 
failed testsuites. So can you add the feature?  Currently I am adding some code 
in the AcceptanceTestMojo.java to allow user decided how many time retry they 
want.  Is that possible to put this into the plugin?  Since this is very 
important feature for us.

protected void subclassExecute() throws MojoExecutionException, 
MojoFailureException {

    if (shouldSkipTests()) {
        getLog().info("RobotFramework tests are skipped.");
        return;
    }
    String[] runArguments = generateRunArguments();

        getLog().info("robotframework arguments: " + StringUtils.join(runArguments, " "));

    int robotRunReturnValue = RobotFramework.run(runArguments);

    /**
     * added by shawna.qian
     * retry the testsuites having failed testcases
     */
    getLog().info("robotRun return code="+ robotRunReturnValue);
    getLog().info("requestedRetryCount="+ requestedRetryCount);

    int retry = 0;
    int iRequestedRetryCount = Integer.parseInt(requestedRetryCount);
    while(robotRunReturnValue >0 && retry < iRequestedRetryCount)
    {
      retry ++;
      getLog().info("retry execution count = " + retry + " times");

      robotRunReturnValue = RobotFramework.run(runArguments);
      getLog().info("retry execution count = " + retry + " time:  robotRun return code="+ robotRunReturnValue);

    }
    /**
     * end of the retry
     */

    evaluateReturnCode(robotRunReturnValue);

}
/**
 * added by shawna.qian
   * The number of retry the user can set when test suites have failed testcases:  only the last one gets reported ; all tests will be re-executed
   * by default it will not be retried
   * @parameter default-value="0"  expression="${maven.test.retry}"
   */
 private String requestedRetryCount;

Original issue reported on code.google.com by shawna.q...@gmail.com on 30 Aug 2012 at 11:09