Karate vs Spock
Asked Answered
A

1

3

I've recently found Karate framework for testing Web Services. But there is also Spock framework providing similar (to my mind) functionality. What are the differences between the frameworks? I would like to suggest our testers to take a look at it.

Ardellaardelle answered 27/7, 2017 at 13:33 Comment(1)
Karate seems to be more specific to web services, while Spock is for any kind of testing (unless you mean Geb). I would suggest doing a spike to compare the two to see how they stack up for your specific needs.Titty
V
8

Developer of Karate here. I have only read about Spock but here's my PoV.

Karate is laser-focused on testing HTTP web-services, and therefore is designed to manipulate and perform assertions on JSON and XML. As a result - you do not need POJO-s any-more.

Whereas Spock is a general-purpose testing framework. It is based on Groovy, so it reduces the verbosity somewhat compared to if you just used Java, and it adds the BDD flavor that is of value in expressing test-cases. Just like Karate, it has a structure to test-cases, a life-cycle (before hooks, environment switching, etc.) data-driven test helpers, and integration with unit-test and reporting frameworks such as JUnit.

A key difference IMO is that while Spock and similar frameworks try to abstract away the verbosity of Java in favor of a cleaner more readable syntax - they succeed only to a certain extent. Karate almost bypasses Java completely (from a test writers PoV) which means that you are operating in the exact 'layer' that you want to - which is HTTP and JSON / XML.

I'd like to point you to this comparison between Karate and REST-assured - since some of the points would apply to Spock as well, and it would be a helpful reference for any team evaluating Karate.

EDIT - Karate's data-driven testing is very similar to Spock, and uses JS (that can do Java interop) instead of Groovy: https://twitter.com/KarateDSL/status/1359369240227106816

Verruca answered 28/7, 2017 at 3:40 Comment(6)
Can one use Karate to test microservices which would need the tool to support mocking services (like in Citrus)Pacificism
@BrianReinhold this is very much in the roadmap. We feel that Karate's DSL is actually a good fit for expressing dynamic, stateful server responses. Do note that Karate has a mock-servlet: github.com/intuit/karate/tree/master/karate-mock-servletVerruca
An update: Karate now has mocks built in ! github.com/intuit/karate/tree/master/karate-nettyVerruca
Hi @PeterThomas, Any suggestion on Karate supporting/suitable for testing Micro services as a whole (not just mocking PoV) especially from Unit testing to component to End to End test using APIs(Micro services)?Vary
@SatyendraSharma Karate can do it all. if you have a specific question, please ask that (as a separate question) to get a better answer.Verruca
@Pete Surely I'll ask if I've any, once started working on it, Currently I'm in evaluation phase i.e. what to use for our MS testing, Thanks a Lot!Vary

© 2022 - 2024 — McMap. All rights reserved.