【问题标题】:Karate + Gatling: exitHereIfFailed not working空手道 + 加特林:exitHereIfFailed 不起作用
【发布时间】:2021-03-09 11:52:07
【问题描述】:

我有这个模拟:

class TestSimulation extends Simulation {
  val protocol = karateProtocol()
  val scn = scenario("test")
    .exec(karateFeature("classpath:test1.feature"))
    .exitHereIfFailed
    .exec(karateFeature("classpath:test2.feature"))

  setUp(
    scn.inject(atOnceUsers(1)).protocols(protocol)
  )
}

test1.feature:

Feature: Test 1
  Scenario:
    * print '1'
    * assert 1 == 2

test2.feature:

Feature: Test 2
  Scenario:
    * print '2'

因为 test1.feature 失败,我希望 Gatling 会在那里停止该场景并且不打印“2”,但在我看到的日志中:

Simulation simulations.TestSimulation started...
05:50:06.217 [DEBUG] i.g.c.c.i.o.OpenWorkload - Start user #1
05:50:06.219 [DEBUG] i.g.c.c.i.o.OpenWorkload - Injecting 1 users in scenario test, continue=false
05:50:06.220 [INFO ] i.g.c.c.i.Injector - StoppedInjecting
05:50:06.411 [DEBUG] c.j.j.i.p.CompiledPath - Evaluating path: $
05:50:06.425 [INFO ] c.intuit.karate - [print] 1
05:50:06.429 [ERROR] c.intuit.karate - assertion failed: assert evaluated to false: 1 == 2
05:50:06.443 [DEBUG] c.j.j.i.p.CompiledPath - Evaluating path: $
05:50:06.445 [INFO ] c.intuit.karate - [print] 2
05:50:06.445 [DEBUG] i.g.c.a.Exit - End user #1

我做错了吗?谢谢!

【问题讨论】:

    标签: karate


    【解决方案1】:

    空手道(可能)不支持.exitHereIfFailed

    也许你可以贡献代码。

    编辑 - 应该在 1.0 中工作:https://github.com/intuit/karate/issues/1382

    【讨论】:

    • 我正在寻找解决方法。也许我可以在会话中使用一些标志来使用来自 Gatling 的 .doIf。我可以在空手道功能中修改 Gatling 会话,还是可以在 karateFeature() 中返回结果?
    • @italktothewind 只需使用 java 单例(如果需要,锁定或同步),您可以做任何您想做的事情。但我认为您应该能够在会话中修改 JSON,可能值得尝试 - 我没有
    • 我无法找到如何在空手道场景中修改 Gatling 会话,也无法从 karateFeature 执行中修改 :(
    • @italktothewind 创建了一个路线图项目。我希望有人为 hacktoberfest 挑选这个:github.com/intuit/karate/projects/3#card-44762585
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多