gpt4 book ai didi

scala - 在 SBT 项目中使用 Karate

转载 作者:行者123 更新时间:2023-11-28 20:36:44 24 4
gpt4 key购买 nike

我正在使用 Karate 在 Scala/SBT 项目中编写集成测试。此外,用 Karate 编写的集成测试也用作性能测试,如 documentation 中所写。

Karate is the only open-source tool that combines web-API testing and test-doubles into a single, unified test automation framework. And you can re-use API Functional Tests as Performance Tests !

在文档的后面,我们注意到我们可以使用 Cucumber Optionsmvn test -Dtest=CatsRunner 的形式启动一个或多个测试。因为所有示例都使用 maven,而我使用 SBT。

所以我尝试使用此命令启动一项测试 sbt test -Dtest=CatsRunner 但没有成功。

您有什么想法可以通过 SBT 启动一项 Karate 测试吗?谢谢:)

最佳答案

最新的 0.8.0 版本引入了不需要 Cucumber 注解的 Java API。这里有一个例子:https://github.com/intuit/karate/blob/master/karate-demo/src/test/java/demo/DemoTestSelected.java

    List<String> tags = Arrays.asList("~@ignore");
List<String> features = Arrays.asList("classpath:demo/cats");
String karateOutputPath = "target/surefire-reports";
KarateStats stats = CucumberRunner.parallel(tags, features, 5, karateOutputPath);

这是为并行执行而设计的。但是您应该很容易在 features 数组中传递单个功能并使用 1 个线程。

我可以在下一个版本中添加运行类似于 JUnit @RunWith(Karate.class) 注释的单个功能的功能,通过 Java API 而不是注释,请随意提交功能请求。如果您搜索该文档,您会找到一种通过 Java API 运行单个功能的方法 - 但它不会发出报告。

关于scala - 在 SBT 项目中使用 Karate ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51746351/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com