2 ms·
I've recently used Karate for contract testing and I have mixed feelings about it. In my case it served me reasonably well. Usually my go-to choice for contract
by jacekm 6y ago
I've recently used Karate for contract testing and I have mixed feelings about it. In my case it served me reasonably well. Usually my go-to choice for contracts is "REST Assured", but in that recent project I had more complex JSONs and I had to write rather lengthy validation rules manually. I felt that rest assured's java-based syntax could quickly turn against me so I was looking for an alternative and someone suggested Karate.
Pros:
* the resulting code was relatively short
* once we got used to Karate the relatively complex tests were quick to write
* the whole framework is really flexible, you can describe complex json structures using just DSL and you can always call a Java method if you are missing something.
Cons
* some of the commenters here already noticed a lengthy README.md - well, you need to read this whole file before starting any work. The framework is reasonably well documented, but you need to ingest the documentation as a whole before attempting to write a test. You cannot just search for "how can I do ___ in Karate", I mean you can try, but you are unlikely to find an answer this way.
* entry point while short is rather steep. You need about 2-3 days before you begin to understand what's going on in the code
* the code is unreadable for bystanders. Good luck with understanding "#[] #(^SOMEVAR)" or "#[_ > 0]"
* the architecture: the whole thing runs on Maven/Java. Java interprets Karate DSL, which can contain Javascript(!) which can call Java again! Yes, you can make a chain of calls Java->DSL->JS->Java! To be fair, it makes the whole framework really flexible, but still, wtf.
Will I ever use it again? Maybe. I'd say it's specific tool for rather specific tasks. It can serve certain purposes quite well. But if you are wondering what framework you should use in your next project - there are much safer choices out there.