如何使用Cucumber和Rally集成自动更新Rally测试用例?

时间:2019-04-09 14:37:49

标签: java cucumber rally qaf

我试图弄清楚如何通过Cucumber自动化脚本为Rally中的测试用例自动更新测试用例结果。我希望能够运行我的测试脚本,该脚本随后将Rally中的测试用例结果自动更新为“通过”或“失败”。

黄瓜有没有办法做到这一点?我将Cucumber与TestNG和Rest Assured一起使用。

1 个答案:

答案 0 :(得分:1)

如果您使用的是TestNG's QAF extension for BDD,则可以通过提供TestCaseResultUpdator来使用测试管理工具来integrate测试结果。在测试用例或场景中,您需要从测试管理工具提供测试用例ID,并调用api以更新该测试用例的测试结果。 QAF支持gherkin,但Gherking不支持自定义元数据。您可以使用BDD2,它是小黄瓜的超集,您的情况可能如下所示:

@smoke @RallyId:TC-12345
Scenario:  A scenario

    Given step represents a precondition to an event
    When step represents the occurrence of the event
    Then step represents the outcome of the event

在上面的示例中,假设RallyId表示测试管理工具中的测试用例ID。您可以在实现结果更新程序时使用它。

package example;
...
public class RallyResultUpdator implements TestCaseResultUpdator{

   @Override
   public String getToolName() {
    return "Rally";
   }

   /**
    * This method will be called by result updator after completion of each testcase/scenario.
    * @param params
    *            tescase/scenario meta-data including method parameters if any
    * @param result
    *            test case result
    * @param details
    *            run details
    * @return
    */

   @Override
   public boolean updateResult(Map<String, ? extends Object> metadata,
        TestCaseRunResult result, String details) {

    String tcid = metadata.get("RallyId");
    // Provide test management tool specific implemeneation/method calls

    return true;
   }
}

按如下所示注册您的更新者:

result.updator=example.RallyResultUpdator

测试用例完成后,结果更新器将由qaf自动调用,并将在单独的线程中运行,因此您的测试执行无需等待。

相关问题