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