visit
On to the topic at hand. I’d like to explain how Karate relates to and BDD. I expect this to be a very frequently asked question as Karate gets more widely adopted — and this blog post is intended to be the definitive reference that I can point folks to from now on.
The decision to build Karate on top of and use the standard — is turning out to be a great one. And here’s why:EDIT / Jan-2019: As of version 0.9.0, Karate is no longer based on Cucumber () — but retains the syntax. And if you are contemplating using BDD for API testing — you should really read .
Karate certainly gives you the option of using the BDD keywords such as Given, When, Then and And. And people familar with Cucumber already know that it doesn’t matter whether you use Given or When or Then, it is just “syntax sugar” and behind the scenes it is completely ignored.
But back to the question. I’d rather not lecture you on how BDD should actually be applied in practice because that is something best articulated by the creators and some opinionated users of Cucumber. Consider the following blog-posts a “must-read” if you are contemplating using Cucumber — or even BDD for that matter. Even if you think that you are doing BDD the Right Way™, I urge you to read these articles. You may be surprised.
Cucumber has its uses, principally as a high level analysis tool on large, polyglot projects. That said, few programmers work in this kind of position, and acceptance tests beyond a list of the method names of regular integration tests seems wasteful. Cucumber, as used by the majority of Rails programmers, is no more than a clumsy wrapper over basic integration tests.
Bingo. I’m sure this will resonate with a lot of folks who have used some flavor of BDD at some point, to write tests for an existing system. And all the while wondering — wouldn’t a plain-old integration-test have sufficed ?
Karate unashamedly embraces the fact that it is for integration-testing of HTTP web-services. And it includes a to simplify the business of doing just that. It competes directly with the likes of in the web-service API testing-tool space — for example, take a look at this .
Karate makes sense especially for “platform” teams creating and maintaining web-services, and where product-owner involvement in acceptance-testing is not the highest priority.But yes, if you are concerned that Karate looks like a programming-language, it certainly is, and by design. It is worth repeating that Karate is not for teams wishing to practice true BDD.
Yes, Karate is for technical folks who need to test web-services and it is laser-focused on making this as simple as possible. The motivation for creating Karate in the first place was to avoid using Java code for web-services, as there is a significant impedance-mismatch. This deserves a whole other blog-post which I hope to do in the future.
Karate also — which arguably don’t belong in a BDD context, but are much-needed from an integration-testing perspective.There is an argument to be made that some languages (e.g. Python and Ruby) can reduce the impedance-mismatch to some extent, but that is debatable — especially since Karate has JSON and XML into the syntax. Anyway, we are already seeing developers as well as quality-engineers create API test-automation at velocities much higher than before. One of the great things about Karate is that it is language-neutral, without sacrificing power or expressiveness for what it is designed to do.
And in closing, don’t knock it till you try it ! I’m by no means un-biased, but I urge you to give Karate a try, or ask your team to evaluate it. I am confident that you will find some good things to say about it over time.