如何使用黄瓜和拉力赛集成自动更新拉力赛测试用例



我正在尝试弄清楚如何通过 Cucumber 自动化脚本自动更新 Rally 中测试用例的测试用例结果。我希望能够运行我的测试脚本,然后这些脚本会自动将 Rally 中的测试用例结果更新为通过或失败。

瓜有什么办法可以做到这一点吗?我正在使用Cucumber以及TestNG和Rest Assured。

如果您使用的是TestNG的QAF扩展用于BDD,它提供了一种通过提供TestCaseResultUpdator将测试结果与测试管理工具集成的方法。在测试用例或方案中,需要从测试管理工具提供测试用例 ID,并调用 api 来更新该测试用例的测试结果。QAF 支持小黄瓜,但小黄瓜不支持自定义元数据。您可以使用 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 自动调用,并将在单独的线程中运行,因此您的测试执行无需等待。

最新更新