While using Karate we were able to do most of the validations for web services, we were able to successfully integrate Karate with Selenium webdriver and do DB assertions using java classes. For DB we returned the results sets as list by converting each row as a hashmap and Karate took it as json array. So the validations became simple. Most of the needs for us on a QA side have been achieved using Karate.
However, today when we introduced, it to a bigger community one of the dev lead came up with a question. He is an expert in JBehave, BDD, jsonpath, java, web services etc. We also felt his question is really relevant based on our context. however, the approach of Karate is different and it may not work according to our knowledge.
In our context, we need to make the BA write the BDD considering their business scenarios using business terms and QA/Dev can later convert these as scripts. (An approach which we usually follow using cucumber + selenium/rest assured etc). For example, if I have a feature file and 10 scenarios in that, people on the business side will not understand the details of validations seeing the steps in karate/ or in another word plain English text will be little more self-explanatory for them. We need this approach because we try to implement process changes from story level itself.
Could you please share your thoughts?
Karate is an open-source general-purpose test-automation framework that can script calls to HTTP end-points and assert that the JSON or XML responses are as expected. Karate is implemented in Java but test-scripts are written in Gherkin since Karate was originally an extension of the Cucumber framework.
Karate Framework is an open-source Behavior Driven Development (BDD) testing framework for API test automation, performance testing, and UI testing.
Both Karate scenarios and Selenium scenarios can be BDD data driven. Framework utilizes TestNG metrics report for both tools integrated. Karate scenarios can be executed with its inbuilt Karate TestNG runner while Selenium scenarios can be executed with the Selenium TestNG runner.
But, parallel execution is built-in for Karate. The only thing to do is create a test method inside the JUnit runner and call the parallel execution function. Above code will execute all of the features under some/package without @ignore tag. Karate will run all the features in parallel default.
Short answer: Karate is not for BDD.
I wrote a detailed blog post about it here: Yes, Karate is not true BDD
Do read it carefully, and share it with those who will benefit. Yes, Karate steals the BDD syntax from Cucumber, but then takes a different direction.
You may be able to use Karate behind the scenes as Cucumber step-definitions via the Java API. Or if you want to use something like REST-assured, full power to you.
My personal opinion is, please don't. You will be wasting time doing this:
EDIT: Look at the second example here to see what happens when you use Cucumber to test what should have been a simple unit or integration test.
EDIT2 (9-Mar-22): In 2021, less than 5 years after Karate was released, it crossed Cucumber in terms of GitHub stars. I recommend that teams consider giving up the pursuit of "pure BDD" and evaluate Karate instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With