1
votes

I am using parallel runner as: 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|

If i am running 3 threads then all the above 3 scenarios will execute together. So the console logs and karate.log file will print it in something this way:

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"}

All the 3 requests will be logged first in console and then all the 3 responses .So now would like to know if it possible to get the request of 1 and response of 1 together? Because when running multiple tests(like 1000+) it becomes difficult to read the logs if the request and response is separated from each other.

Something like below would be good.

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"}

Again I know that the karate report and also cucumber report gives/shows this properly and are very handy but sometimes devs prefer referring to build logs in CI/CD and then its difficult to understand the failure from logs. Let me know if there is some config i can change in logback xml or log4j file so that this can be merged together and printed to console log.

1

1 Answers

1
votes

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

There is no reason to NOT use the HTML reports. I'm sorry, logs are like that - you WILL see multiple threads merge into one. If you know how to make it work the way you are expecting, you are welcome to contribute code, Karate is an open source project.