且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Cucumber-JVM 中并行运行场景?

更新时间:2023-01-15 14:44:20

由于cucumber-jvm包的特性,测试并行化暂时受限.未来有一些改变 API 的暂定计划(gherkin3、cucumber-jvm v2),但现在 cucumber-jvm 上没有任何东西可用于完全并行化.

Due to the nature of the cucumber-jvm package, test parallelization is limited for the time being. There are tentative plans for the future to change the API (gherkin3, cucumber-jvm v2), but nothing is available for full parallelization now on the cucumber-jvm.

仍然有一种方法可以在 cucumber-jvm 上获得一定程度的并行性.Zucchini 包 (https://github.com/Comcast/Zucchini) 可以通过提供上下文级别来提供帮助并行性,如果您必须针对 Android/iOS/Chrome/等运行一系列测试,这可能会有所帮助.然后将测试结果合并到一个报告中.

There is still a way to attain a degree of parallelism on the cucumber-jvm. The Zucchini package (https://github.com/Comcast/Zucchini) can help by providing context-level parallelism, which could help if you have to run a battery of tests against Android / iOS / Chrome / etc. Test results are then merged into a single report.

要开始使用 Zucchini,请创建一个扩展 AbstractZucchiniTest 并使用 @CucumberOptionsZucchiniOutput 标记的新测试类.然后该类应该实现 List<TestContext>getTestContexts() 方法返回您的专用上下文列表.

To start using Zucchini, create a new test class that extends AbstractZucchiniTest and is tagged with @CucumberOptions and ZucchiniOutput. The class should then implement the List<TestContext> getTestContexts() method that returns a list of your specialized contexts.

Zucchini 还提供其他功能,例如跨上下文屏障同步和将测试输出汇总到 HTML 报告中.如果您已经进行了 Cucumber 测试,那么将它们升级到 Zucchini 测试并没有什么太大的关系.

Zucchini also provides other features such as cross-context barrier synchronization and aggregated test output into an HTML report. If you already have cucumber tests, there isn't much involved in upgrading them to Zucchini tests.