karate - 通过命令行运行时有没有办法输出漂亮的报告?

标签 karate

通过命令行运行 Karate 时有没有办法输出漂亮的报告?

运行这个:

java -jar karate-0.9.1.jar tests/*.feature

产生这个:

15:32:56.363 [main] INFO  com.intuit.karate.netty.Main - Karate 
version: 0.9.1
15:32:56.466 [main] INFO  com.intuit.karate.Runner - Karate version: 
0.9.1
15:32:56.868 [ForkJoinPool-1-worker-1] WARN  com.intuit.karate - 
skipping bootstrap configuration: could not find or read file: 
classpath:karate-config.js
15:32:57.065 [ForkJoinPool-1-worker-1] DEBUG com.intuit.karate - 
request:
1 > GET http://localhost:8080/ping
1 > Accept-Encoding: gzip,deflate
1 > Connection: Keep-Alive
1 > Host: localhost:8080
1 > User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_191)

15:32:57.114 [ForkJoinPool-1-worker-1] DEBUG com.intuit.karate - 
response time in milliseconds: 47.35
1 < 200
1 < Content-Length: 18
1 < Content-Type: application/json; charset=utf-8
1 < Date: Wed, 16 Jan 2019 15:32:57 GMT
1 < X-Request-Id: ffa3630d-19a3-11e9-bbab-0242ac180007
{"message":"pong"}

15:32:57.138 [ForkJoinPool-1-worker-1] ERROR com.intuit.karate - 
assertion failed: path: $.message, actual: 'pong', expected: 
'pong2', reason: not equal
15:32:57.163 [ForkJoinPool-1-worker-1] INFO  
com.intuit.karate.Runner - <<fail>> feature 1 of 1: 
tests/ping.feature
---------------------------------------------------------
feature: tests/ping.feature
report: target/tests.ping.json
scenarios:  1 | passed:  0 | failed:  1 | time: 0.2609
---------------------------------------------------------
Karate version: 0.9.1
======================================================
elapsed:   0.70 | threads:    1 | thread time: 0.26
features:     1 | ignored:    0 | efficiency: 0.37
scenarios:    1 | passed:     0 | failed: 1
======================================================
failed features:
tests.ping: ping.feature:8 - path: $.message, actual: 'pong', 
expected: 'pong2', reason: not equal

Exception in thread "main" picocli.CommandLine$ExecutionException: 
there are test failures
    at 
com.intuit.karate.netty.Main$1.handleExecutionException 
(Main.java:118)
    at picocli.CommandLine.parseWithHandlers(CommandLine.java:1157)
    at com.intuit.karate.netty.Main.main(Main.java:124)

这更像是日志而不是报告。

我知道 Karate 会生成漂亮的 HTML 报告,但是当您想要快速识别失败的测试时,这在 CI 管道中并不是真正有用。

与此类似的东西会很棒:

Feature: 

  Scenario: 
      Before hook
    Given this step passes
      AfterStep hook
      After hook
      error (RuntimeError)
      ./features/step_definitions/output_steps.rb:11:in `After'

Failing Scenarios:
cucumber features/test.feature:2

1 scenario (1 failed)
1 step (1 passed)

最佳答案

这是我的建议,如果您确实觉得需要更清晰的报告 - 请编写一个小实用程序来处理 target/cucumber-html- 中的所有 *.json 文件 - reports 文件夹。 所有您要求的信息 - 甚至行号都包含在这些 JSON 文件中。

您可以使用此功能请求作为引用 - 我们在其中添加了一个 JSON 文件以“自动化友好”的方式输出统计信息:https://github.com/intuit/karate/issues/561

由于您是迄今为止唯一提出此要求的人,因此我们不太可能接受此问题 - 除非我们得到某种社区贡献。希望这是有道理的。

关于karate - 通过命令行运行时有没有办法输出漂亮的报告?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54220486/

相关文章:

json - 如何在 Karate 中将变量用作 json 键?

Karate 模式验证,使用匹配包含断言时它是否可以与嵌套数组一起使用?

nashorn - Karate 中具有 undefined variable 的三元条件逻辑

karate - 是否可以覆盖被调用的功能文件中已在后台或场景中定义的参数?

graphql - 将片段从 GraphQL 文件导入到另一个 GraphQL 文件不起作用

testng - Karate/ cucumber 新手:The baseUrl in karate-config is not recognized

cucumber - Karate API 测试 - 在功能文件的 url 中转义 '?'

web-services - Karate 自动设置 Content-Type header

java - Karate Spring 整合

api - 在Karate Scenario Outline测试中,如何通过变量传递Examples表中的参数值