简体   繁体   English

隔离执行功能,但并行包含场景

[英]Executing Feature in isolation, but contained Scenarios in parallel

I have a large-ish and rapidly growing body of karate tests and use the parallel execution to speed up processing, which basically works great in different configurations:我有一个庞大且快速增长的空手道测试主体,并使用并行执行来加速处理,这在不同的配置中基本上工作得很好:

  • Normal parallel execution (vast majority of tests)正常并行执行(绝大多数测试)
  • Sequential execution of Scenarios within a Feature ( parallel=false ) for very few special cases在极少数特殊情况下,在功能 ( parallel=false ) 中顺序执行场景
  • Completely sequential execution (via separate single-threaded runner, triggered by custom @sequential tag) for things that modify configuration settings, global lookups etc完全顺序执行(通过单独的单线程运行器,由自定义@sequential标记触发)修改配置设置、全局查找等

There's however also a parameterized (Scenario Outline) feature for the basic functionality of many types of global lookups.然而,对于许多类型的全局查找的基本功能,还有一个参数化(场景大纲)功能。 Currently it runs in the "completely sequential" mode because it affects other tests.目前它以“完全顺序”模式运行,因为它会影响其他测试。 But actually the scenarios inside that feature could be executed in parallel (they don't affect each other) as long as the Feature as a whole is executed in isolation (because the tests do affect other Features).但实际上该功能中的场景可以并行执行(它们不会相互影响),只要该功能作为一个整体是隔离执行的(因为测试确实会影响其他功能)。

So - is there a way to implement "sequential Features with parallel Scenarios" execution?那么 - 有没有办法实现“具有并行场景的顺序功能”执行? I admit that this is likely a niche case, but it would speed up tests execution quite a bit in my case.我承认这可能是一个小众案例,但在我的案例中它会大大加快测试执行速度。

... and posting this question already got the ideas flowing and pointed me to a possible way to implement this: ...并发布这个问题已经让想法流动起来,并指出了一种可能的实现方式:

  private static void runLocalParallel(Builder<?> builder) {
    final List<Feature> features = builder.tags("@local_parallel").resolveAll();

    for (Feature feature : features) {
      builder.features(feature).parallel(8);
    }
  }

This identifies all features tagged with @local_parallel , iterates over them and executes a parallel runner for each individually.这会识别所有标记有@local_parallel的特征,迭代它们并为每个单独执行一个并行运行器。 Result handling, report output etc still needs to be implemented in an elegant manner, but that's doable as well.结果处理、报告 output 等仍然需要以优雅的方式实现,但这也是可行的。

Yes, indeed an edge case - but it has come up a few times.是的,确实是一个边缘案例——但它出现过几次。 We've wondered about a way to "bucketize" threads, which means we can do things like say that certain tags have to be run only on particular thread.我们想知道一种“分桶”线程的方法,这意味着我们可以做一些事情,比如说某些标签必须只在特定线程上运行。 Come to think of it, that's a good feature request, so I opened one, feel free to comment.想想看,这是一个很好的功能请求,所以我打开了一个,请随时发表评论。 https://github.com/karatelabs/karate/issues/2235 https://github.com/karatelabs/karate/issues/2235

In theory if you write some Java glue code that holds a lock, you can call that code before entering any "critical" feature.理论上,如果您编写一些持有锁的 Java 粘合代码,您可以在输入任何“关键”功能之前调用该代码。 I haven't tried it, but may be worth experimenting.我没有尝试过,但可能值得尝试。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我将 @parallel=false 保留在我的功能级别,并且场景没有并行执行,但所有功能文件都在并行执行 - I have kept @parallel=false at my feature level and scenarios are not executing parallel but all the feature files are executing parallel 在空手道中并行运行时,是否可以在运行器 window 的功能文件中查看场景? - Is it possible to see scenarios in feature files in the runner window while running parallel in karate? 空手道响应正在覆盖并行场景 - Karate response is overwriting for parallel scenarios 空手道 dsl - 运行并行功能和场景 - karate dsl - running parallel features and scenarios 功能文件中的空手道强制场景在多个线程上顺序执行 - Karate force scenarios inside a feature file to execute sequentially on multiple threads 从具有多个场景的特征文件中返回变量 - 空手道 - Returning Variable from Feature File With Multiple Scenarios - Karate 有什么办法可以用@env 标签划分的场景来调用功能文件吗? - Is there any way to call the feature file with scenarios divided by @env tags? 空手道 API 测试 - 在同一功能文件中的不同场景中重用变量 - Karate API Testing - Reusing variables in different scenarios in the same feature file 如何使用 Karate 为单个功能文件中的场景重用断言? - How to reuse assertions for scenarios in single feature file using Karate? 空手道 - 如何在单个功能文件中并行运行多个场景? - Karate - how to run multiple scenarios in a single feature file parallely?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM