karate

How to make a Odata batch call in karate

99封情书 提交于 2019-12-24 12:27:14
问题 I need to make Odata call to fech the results from downsream APIs. I am using karate to test our APIs. But now i need to fech the data from downstream APIand compare it with our APIs result. My problem is downstream APIs are Odata request. Can i make Odata batch request from karate. if yes how? Request header is: Content-Type = 'multipart/mixed;boundary=batch_01' and Request body is: --batch_01 Content-Type: application/http Content-Transfer-Encoding: binary GET test(test1='ABC',test2='12345'

Does the callonce function executes the feature again if i use use in this function multiple times in different features?

百般思念 提交于 2019-12-24 11:58:05
问题 I have multiple feature files in my project. One of the feature file creates tokens. I want to call this feature only once at the start of the test and then use the tokens in the other feature without executing the token feature again and again. Can someone please help me with this ? 回答1: Look at callSingle() in karate-config.js and please refer the docs: https://github.com/intuit/karate#hooks var result = karate.callSingle('classpath:tokens.feature'); 来源: https://stackoverflow.com/questions

How to pass variable into the title of a scenario/scenario title in Karate framework

帅比萌擦擦* 提交于 2019-12-24 11:57:20
问题 While using data-driven feature in Karate framework, I see the generated report just show the title as configured in Scenario Outline NOT attached the value using in Example table. It causes the Tester confuse which data is using, and take time to expand each scenarios to know which data is using; so I want the report can pass variable into the title - Scenario/Scenario Outline. Please take a look at the example below. E.g. Feature: Login Feature Background: * configure headers = { 'Webapp

Can we access spring bean in Karate feature?

烂漫一生 提交于 2019-12-24 11:22:50
问题 I have a class like below, can I access the myServer object or call handleOperation() method (which can use the injected bean) in Karate Feature file? If yes then may I know how? @RunWith(SpringRunner.class) @SpringBootTest(classes = {MyApiApp.class}, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) @ContextConfiguration(classes = {AcceptanceTestConfiguration.class}) @ActiveProfiles("test") @KarateOptions(features = "classpath:acceptanceTest/api/myapi.feature", tags = "@myapi")

KARATE : can not see print statements on console in karate

↘锁芯ラ 提交于 2019-12-24 10:55:19
问题 KARATE : can not see print statements on console in karate I am unable to see print statements on console when I write print statements in feature file using javascript here is my code : Scenario: Get list of channels Given url 'https://slack.com/api/channels.list?token='' When method get Then status 200 * print 'Response is: 'response * def obj = (response.channels[0].length) * print 'LENGTH OF AN ARRAY IS: 'obj 回答1: before (problem): print 'LENGTH OF AN ARRAY IS: 'obj After (fixed): print

Unable to Parse the variable value to the array variable

时光总嘲笑我的痴心妄想 提交于 2019-12-24 10:47:14
问题 I was trying to pass the variable 'i' value to a array index 'locations[i]' using below karate code. but throwing an error saying unable to parse. Please suggest be for any changes. Feature: Verify Branches Background: For loop implementation Given url '' When method GET Then status 200 * def i = 0 * def z = $.locations[i].zip * def p = $.locations[i].phone * def fun = """ function(locations){ for (var i = 0; i < locations.length; i++) { print(i) print('Element at Location ' + i +':' + p) } }

Karate - Not able to run dynamic scenario outline in a loop

为君一笑 提交于 2019-12-24 10:23:14
问题 Here is my feature file , which just loads the json file and wants to iterate over the same Background: * def kittens = read('../json/test.json') Scenario Outline: cat name: <name> * print <name> Examples: | name | | kittens | Here is the output [ { "name": "Bob" }, { "name": "Wild" }, { "name": "Nyan" }, { "name": "Keyboard" }, { "name": "LOL" }, { "name": "Ceiling" } ] As per my understanding this should run 7 times and give me individual variable values , But its running only once and

How to use karate.callSingle() in karate-config.js?

廉价感情. 提交于 2019-12-24 08:49:11
问题 I am using an authorization token in all my feature files . To generate the authorization token i need to call a particular feature file(token.feature) . Since I am using the token in all features I keep calling the same feature file again and again. The solution i found is the use of karate.callSingle() in karate-config.js but i dont know how to use karate.callSingle(). 回答1: In karate-config.js you can do this: var config = { myprop: 'myvalue', myurl: 'somevalue' }; var result = karate

How to loop through karate response array and pass this in json path of another web service response

為{幸葍}努か 提交于 2019-12-24 08:47:42
问题 I am using Karate version 0.8.0.1 and I want to perform following steps to test some responses. I make a Get to web service 1 find the value for currencies from the response of web service 1 using jsonpath: $.currencies Step 2 gives me following result: ["USD","HKD","SGD","INR","GBP"] Now I use Get method for web service 2 From the response of web service 2 I want to get the value of price field with json-path something like below(passing the values from step 3 above): $.holding[?(@.currency=

How to compare 2 JSON objects using Karate tool

二次信任 提交于 2019-12-24 08:46:52
问题 URL 1 --> post request --> JSON respose 1 URL 2 --> post request --> JSON respose 2 How to compare response 1 and response 2 ? response 2 will have extra attributes so cannot directly use match command Response1 { name : hello, country : ABCD} Response2 { name : hello, country: ABCD, state: xyz} Want to compare only name and country attributes and don't want to hardcode comparison like match response1.name == response2.name In future extra attributes may be added and don't want to modify the