Beruflich Dokumente
Kultur Dokumente
to @ptrthomas
REST-assured Karate References / Comments
1 BDD Syntax Yes Yes
2 True DSL No. Fluent Interface. Yes DSL vs Fluent Interface.
Also IDE formatting is a challenge Also see (24) and (25)
3 Runs on the JVM Yes Yes
4 Implementation Java and Groovy Java
5 Code-base Size Large. Medium. Karate has API-mocks,
perf-testing and UI
40,000 lines of code (source: OpenHub) 30,000 lines of code (source: OpenHub) automation as well.
6 Mature Yes. Inception 2010. Yes. Inception February 2017. 2000+ GitHub “stars” in 2
years
Lots of blog posts, tutorials and Clear signs of wide and rapid adoption.
StackOverflow posts. The quality of documentation
In the ThoughtWorks Tech Radar within and examples is arguably way
In the ThoughtWorks Tech Radar at 5 years. just 2 years. better for Karate.
38 Floating-point All numbers are converted to float and you Numeric assertions work just as you
precision shouldn’t forget to use floats (not the expect and even auto-conversion to Even this works:
default double) in assertions. BigDecimal happens if needed.
And $.odd.ck ==
get("/odd") Given path ‘odd’ 12.2000000000000
.then().assertThat() When method get
.body("odd.ck", equalTo(12.2f)); Then $.odd contains { ck: 12.2 }
39 Lines of Code Needed More. By nature, Java is verbose and Less. Another example of how Java
to express a test especially if you depend on POJO “gets in the way” - the
representations of payloads - you need This particular comparison shows a contortions you need to do to
more Java code in place. dramatic difference, 431 lines of code handle JSON arrays in
reduced to 67 REST-assured.
40 Test Reports Built-in No, you have to use JUnit, TestNG or Karate has text and HTML reports out of Here is an example of the very
equivalent for test reporting. the box and you get the option of nice-looking reports you can
choosing from the Cucumber ecosystem get by using the
of 3rd party reports. cucumber-reporting library.
41 Test any Java servlet REST-assured has support for Karate v0.5.0 onwards has support for This is possible because of
or HTTP resource “out-of-container” testing of specifically testing any servlet by providing Karate’s pluggable abstraction
without a container Spring-MVC but your tests will be extension points for teams to write an of the HTTP Client. Refer to
“hard-coded” in this mode. adapter. the documentation for more
details.
There is no support for things like JAX-RS or The huge advantage of Karate’s
custom servlets or controllers - and for approach is that the same test-script can You will be able to quickly
these you have to deploy to an app-server. be re-used for http-integration tests implement a custom adapter
without changes. for any Java server-side stack
in a similar way.
42 Report includes HTTP No. Karate 0.6.0 onwards includes HTTP
request and response request and response logs in the JSON
logs in-line report output. If you use the print
keyword, the console output appears in
the report as well, which is great for
troubleshooting. All this works even
when tests are run in parallel.
43 Construct JSON or No. Karate’s set keyword was enhanced in
XML from scratch v0.6.0 to support a ‘builder’ approach
using just path using cucumber tables. This is best
expressions explained via some examples.
44 Test Doubles or No. Karate 0.7.0 onwards has support for Karate is a superior alternative
Mocks built-in creating API mocks that can fully to Wiremock, here’s a
You have to use 3rd party frameworks such simulate stateful CRUD. Having both a comparison.
as Wiremock client and server in the same unified
framework keeps things simple and you Also see this perf benchmark.
can move fast.
45 Performance Testing No. Karate 0.8.0 onwards has support for This alone is reason to choose
re-using Karate tests as Gatling Karate and no other
Also see [37] performance tests. open-source test-automation
framework has this option.
You can compose multiple Karate
feature files or “work-flows” into a single In 0.9.0 onwards you can test
performance-test and use Gatling to any Java code, not just HTTP
define the load-model (ramp-up,
concurrent users, etc)
46 Websockets support No. Karate 0.9.0 onwards has support for
websockets and even generic async /
await support (see below)
47 Async Support No, you have to use Java code or a library Karate 0.9.0 has built-in support via a
like Awaitility very elegant API.
48 Retry Support No, you have to write custom Java logic. Karate 0.9.0 onwards has this built-in -
where you only specify the condition to
be polled for.
49 CSV file support No, you have to use Java code or a library. In Karate 0.9.0 you can read a CSV file Karate also has YAML file
and it will be auto-converted to JSON support out of the box.
50 Web-UI Automation No. In Karate 0.9.5 onwards Web-UI
automation is possible.
51 Distributed Testing No. In Karate 0.9.5 onwards, there is built-in
support to split a test-suite and
orchestrate the execution across
multiple cloud or hardware / cluster
nodes