Releases: karatelabs/karate
v0.2.7
New Features
Parallel Execution
This is a huge time-saver and significantly differentiates Karate from the competition: Parallel Execution
IDE Integration
Earlier it was not possible to 'right click and run' a *.feature
file in IntelliJ or Eclipse when using the Cucumber plugin / support. This is fixed and even switching the environment by passing for e.g. -Dkarate.env=e2e
from the IDE 'run configuration' - works just like you would expect.
configure headers
supports JSON in addition to a JS Function
Sometimes you just want the same hard-coded headers for all requests and a function would be over-kill. The documentation has been updated for configure headers
and so has the demo example.
v0.2.6
The new behavior of `karate.get' in v0.2.5 caused a regression / break in headers routine (call) handling. This was fixed and multiple unit test cases have been added to prevent this happening in the future.
If you are upgrading from v0.2.4 or earlier, there are some breaking changes, please refer to the detailed release notes: https://github.com/intuit/karate/releases/tag/v0.2.5
v0.2.5
Breaking Changes
TestNG runner base class name change
KarateTest
was re-named to KarateRunner
to be consistent with the recommended naming conventions.
Before:
import com.intuit.karate.testng.KarateTest;
public class SmokeTest extends KarateTest {
After:
import com.intuit.karate.testng.KarateRunner;
public class SmokeRunner extends KarateRunner {
JS karate
object does not support HTTP calls anymore
The karate.request()
method is not available, so the below will not work any more.
var req = { url: loginUrlBase, method: 'post', body: { name: 'foo' } };
var res = karate.request(req);
This is because the ability to call other *.feature
files introduced in v0.2.4 is sufficient for making (re-usable) calls. Do note that you can now make a call
from JavaScript if really needed as described later.
New Features
JS karate
object has a call
method
The signature is karate.call(fileName, [arg])
and this works the same way that the call
keyword works.
get
keyword introduced
Now you can save the results of JsonPath expressions to variables:
* def cat =
"""
{
name: 'Billie',
kittens: [
{ id: 23, name: 'Bob' },
{ id: 42, name: 'Wild' }
]
}
"""
* def kitnums = get cat.kittens[*].id
* match kitnums == [23, 42]
* def kitnames = get cat.kittens[*].name
* match kitnames == ['Bob', 'Wild']
JS karate
object get
method now supports JsonPath expressions
* def foo = { bar: [{baz: 1}, {baz: 2}, {baz: 3}]}
* def fun = function(){ return karate.get('foo.bar[*].baz') }
* def res = fun()
* match res == [1, 2, 3]
table
keyword introduced
This is a super-elegant and easy way to convert a Cucumber data-table into JSON.
* table cats =
| name | age |
| Bob | 2 |
| Wild | 4 |
| Nyan | 3 |
* match cats == [{name: 'Bob', age: 2}, {name: 'Wild', age: 4}, {name: 'Nyan', age: 3}]
Calling *.feature
files in a loop for dynamic data-driven testing
If the argument to a *.feature
call
is an array, the call will loop over the array. More details at data-driven features.
* table kittens =
| name | age |
| Bob | 2 |
| Wild | 1 |
| Nyan | 3 |
* def result = call read('cat-create.feature') kittens
v0.2.4
*.feature
files are re-usable
And can be called from other test scripts.
This is huge and pushes the underlying Cucumber-JVM framework beyond what it normally supports. There is no more need to use JavaScript for common 'set up' HTTP calls or authentication flows.
Read more at the documentation here: Calling Other *.feature
Files. And the Karate Demos project has added an example for this as well.
v0.2.3
Breaking Change:
multipart post
replaced with method post
multipart post
has been removed and a simple method post
will suffice. The steps of multipart field
or multipart entity
are sufficient to determine user intent, and that would drive the behavior of the next POST. So now only soap action
is the odd man out (as the only other step besides method
that issues the HTTP request to the server), which should be fine.
# before
And multipart field file = read('test.pdf')
When multipart post
# after
And multipart field file = read('test.pdf')
When method post
Notable Fixes:
#23 Much better reporting of match failures especially when large arrays are in the picture.
#8 A set of nice, real-life examples are available now in the karate-demo sub-folder
v0.2.2
Fixed #21 - relative file paths confused the parser into thinking it was xpath
Fixed #22 - archetype package had typo
Now conditional (equality) validation where $
refers to the JSON root is possible using embedded expressions:
Given def temperature = { celsius: 100, fahrenheit: 212 }
Then match temperature == { celsius: '#number', fahrenheit: '#($.celsius * 1.8 + 32)' }
Given def json =
"""
{
"hotels": [
{ "roomInformation": [{ "roomPrice": 618.4 }], "totalPrice": 618.4 },
{ "roomInformation": [{ "roomPrice": 679.79}], "totalPrice": 679.79 }
]
}
"""
Then match each json.hotels == { roomInformation: '#array', totalPrice: '#($.roomInformation[0].roomPrice)' }
v0.2.1
The main enhancement is the ability to refer to the root doc via $
in validation expressions and enable insane things like this:
Given def temperature = { celsius: 100, fahrenheit: 212 }
Then match temperature contains { fahrenheit: '#? _ == $.celsius * 1.8 + 32' }
Given def json =
"""
{
"hotels": [
{ "roomInformation": [{ "roomPrice": 618.4 }], "totalPrice": 618.4 },
{ "roomInformation": [{ "roomPrice": 679.79}], "totalPrice": 679.79 }
]
}
"""
Then match each json.hotels contains { totalPrice: '#? _ == $.roomInformation[0].roomPrice' }
v0.2.0
Breaking changes:
With the introduction of TestNG support, JUnit support had to be factored out into a new Maven module.
Maven artifact has changed
<dependency>
<groupId>com.intuit.karate</groupId>
<!-- before -->
<!-- <artifactId>karate-core</artifactId> -->
<!-- after -->
<artifactId>karate-junit4</artifactId>
<version>0.2.0</version>
<scope>test</scope>
</dependency>
Package name change for JUnit runner
There is a change to the package name.
// before
import com.intuit.karate.Karate;
// after
import com.intuit.karate.junit4.Karate;
Header manipulation is now set via configure
headers
is no longer a magic variable. use the configure headers
syntax to set up header manipulation.
# before
* def headers = read('my-header-function.js')
# after
* configure headers = read('my-header-function.js')
How to enable SSL has changed
enabling ssl is now via the unified configure
syntax
# before
* ssl enabled
# after
* configure ssl = true
New: HTTP time outs
Now http read and connection timeouts can be configured.