并行执行测试时,控制台日志和 Karate.log 文件难以读取,因为服务调用和响应未一起记录

Console logs and Karate.log file are difficult to read when executing tests in parallel because the service call and responses are not logged together

我正在使用平行流道作为:https://github.com/intuit/karate/blob/master/karate-demo/src/test/java/demo/DemoTestParallel.java

Scenario Outline: Basic test for user 
When url 'xyz'
And path 'abc/efg.json'
And params id = 
When method get
Then status 200

Example:
|userID|
|1|
|2|
|3|

如果我是运行 3 个线程,那么以上3 个场景将一起执行。所以控制台日志和 karate.log 文件将以这种方式打印它:

14:22:00:962 com.intuit.karate - request:
1>url: xyz/abc/efg.json
1>id= 1
1>accept-encoding: gzip,deflate
1>connection: keep-alive
1>Host: sgldter

14:22:00:962 com.intuit.karate - request:
2>url: xyz/abc/efg.json
2>id= 2
2>accept-encoding: gzip,deflate
2>connection: keep-alive
2>Host: sgldter

14:22:00:962 com.intuit.karate - request:
3>url: xyz/abc/efg.json
3>id= 3
3>accept-encoding: gzip,deflate
3>connection: keep-alive
3>Host: sgldter


14:23:10:962 [main] Debug com.intuit.karate - response in milliseconds :220

1>200
1>cache-control: no-cache
1>connection: keep-alive
{"id"="1"}

14:23:12:962 [main] Debug com.intuit.karate - response in milliseconds :230

3>200
3>cache-control: no-cache
3>connection: keep-alive
{"id"="3"}

14:23:13:962 [main] Debug com.intuit.karate - response in milliseconds :240

2>200
2>cache-control: no-cache
2>connection: keep-alive
{"id"="2"}

所有 3 个请求将首先记录在控制台中,然后是所有 3 个响应。所以现在想知道是否可以同时获得 1 的请求和 1 的响应?因为当 运行 多次测试(如 1000+)时,如果请求和响应彼此分离,则很难读取日志。

像下面这样的东西会很好。

14:22:00:962 com.intuit.karate - request:
1>url: xyz/abc/efg.json
1>id= 1
1>accept-encoding: gzip,deflate
1>connection: keep-alive
1>Host: sgldter

14:23:10:962 [main] Debug com.intuit.karate - response in milliseconds :220

1>200
1>cache-control: no-cache
1>connection: keep-alive
{"id"="1"}

14:22:00:962 com.intuit.karate - request:
2>url: xyz/abc/efg.json
2>id= 2
2>accept-encoding: gzip,deflate
2>connection: keep-alive
2>Host: sgldter

14:23:13:962 [main] Debug com.intuit.karate - response in milliseconds :240

2>200
2>cache-control: no-cache
2>connection: keep-alive
{"id"="2"}


14:22:00:962 com.intuit.karate - request:
3>url: xyz/abc/efg.json
3>id= 3
3>accept-encoding: gzip,deflate
3>connection: keep-alive
3>Host: sgldter

14:23:12:962 [main] Debug com.intuit.karate - response in milliseconds :230

3>200
3>cache-control: no-cache
3>connection: keep-alive
{"id"="3"}

我再次知道空手道报告和黄瓜报告 gives/shows 这正确并且非常方便但有时开发人员更喜欢参考 CI/CD 中的构建日志然后很难理解失败日志。 让我知道是否有一些我可以在 logback xml 或 log4j 文件中更改的配置,以便可以将其合并在一起并打印到控制台日志。

Again I know that the karate report and also cucumber report gives/shows this properly and are very handy

没有理由不使用 HTML 报告。对不起,日志就是这样——你会看到多个线程合并为一个。如果你知道如何让它按照你期望的方式工作,欢迎你贡献代码,空手道是一个开源项目。