karate

Karate API Tests - Escaping '?' in the url in a feature file

Deadly 提交于 2019-12-09 22:38:20
问题 I am using the path keyword from Karate API framework to concatenate strings to form a url. However, I am not able to pass '?'. Here is what I am doing: Background: * url 'https://api.cloud.abcde.com/animal/' Scenario: Verify the get status Given path 'herbivore?id=25' When method get Then status 200 When I run the test, i see the '?' being passed as %3F. I tried to escape it using \ and tried some other answers too but couldn't succeed. Do I need to use url encoding ? Any pointers or help

Is there a function like call karate.callSingle() to call a feature file at the end of execution?

扶醉桌前 提交于 2019-12-08 10:17:20
问题 Using karate.callSingle() I am able to create some global resources which are used across different features . I want to delete these resources at the end of each automation run . Is there a function similar to karate.callSingle()such that I can call a feature file(This feature deletes all the global resources) using that function and this feature file will be executed at the end of each automation. This will be helpful in parallel execution also. 回答1: Normally it is better to rely on hooks

karate - How to set specific values in a feature file which is called internally

早过忘川 提交于 2019-12-08 07:03:03
问题 This is my framework structure currently CreateDiscount.feature Discount_Payload.json SearchDiscount.feature Search_Payload.json This is how the code in each file looks CreateDiscount.feature Scenario: Create a discount * def changes = read('Discount_Payload.json') * set changes.code = cu.getCouponCode(4) * set changes.operator = 'LT' Given url baseUrl + CREATE_DISCOUNT And request changes When method post Then status 200 Discount_Payload.json { "code": "ND12", "name": "NDS coupon Testing",

KARATE: Loop over a feature file fails when I call a feature file with scenario outline

此生再无相见时 提交于 2019-12-08 06:09:46
问题 I have 2 feature files and trying to perform below operation **FEATURE 1:** calling.feature Feature: Test loop over by calling a feature file Scenario Outline: Testing loop over feature file * call read('called.feature') { argument = '<arg>' } Examples: |arg| |"HELLO"| |"WORLD"| **FEATURE 2:** called.feature Feature: Test loop over in Karate framework Scenario Outline: Testing loop over feature * def callingArg = arg * match '' == callingArg Examples: |arg2| |"TEST1"| |"WORLD"| When I call

in Karate DSL, how do you escape single quotes when passing a variable within a java argument call

岁酱吖の 提交于 2019-12-08 05:00:52
问题 I'm trying to add making calls to a database as part of an end to end effort with the API project at work. How would I escape single quotes within a variable that is being passed as an argument within an assert method. I have tried the following and it did not work. assert JavaClass.executeSQLQuery('SELECT COUNT(*) As Result FROM PartType WHERE reference = 'evaluate';', '1') == true ERROR is that it cannot evaluate the single quotes within the value Other Attempts def sqlQuery = """ SELECT

Karate array field become object

喜夏-厌秋 提交于 2019-12-08 02:47:34
问题 I've got this really weird problem. I want to append two lists into one list, but it seems like Karate does not support this function, so I write a JS function. function(lists){ var arr = [] for each (var list in lists){ for each (var item in list){ arr.push(item); } } return arr; } And I write this feature file for testing: Feature: Scenario: * def appendList = read('../utils/append-list.js') * def arr = [{a: 'a'}, {b: 'b'}, {c: 'c'}] * def arr1 = [{a: 'a'}, {b: 'b'}, {c: 'c'}] * def arr2 =

KARATE: Loop over a feature file fails when I call a feature file with scenario outline

你。 提交于 2019-12-06 16:56:42
I have 2 feature files and trying to perform below operation **FEATURE 1:** calling.feature Feature: Test loop over by calling a feature file Scenario Outline: Testing loop over feature file * call read('called.feature') { argument = '<arg>' } Examples: |arg| |"HELLO"| |"WORLD"| **FEATURE 2:** called.feature Feature: Test loop over in Karate framework Scenario Outline: Testing loop over feature * def callingArg = arg * match '' == callingArg Examples: |arg2| |"TEST1"| |"WORLD"| When I call 'Called.feature' using read in 'Calling.feature' I was expecting it will iterate using across all the

in Karate DSL, how do you escape single quotes when passing a variable within a java argument call

跟風遠走 提交于 2019-12-06 15:31:41
I'm trying to add making calls to a database as part of an end to end effort with the API project at work. How would I escape single quotes within a variable that is being passed as an argument within an assert method. I have tried the following and it did not work. assert JavaClass.executeSQLQuery('SELECT COUNT(*) As Result FROM PartType WHERE reference = 'evaluate';', '1') == true ERROR is that it cannot evaluate the single quotes within the value Other Attempts def sqlQuery = """ SELECT COUNT(*) As Result FROM PartType WHERE reference = 'updateerferencee'; """ assert JavaMethods

Karate array field become object

核能气质少年 提交于 2019-12-06 09:51:08
I've got this really weird problem. I want to append two lists into one list, but it seems like Karate does not support this function, so I write a JS function. function(lists){ var arr = [] for each (var list in lists){ for each (var item in list){ arr.push(item); } } return arr; } And I write this feature file for testing: Feature: Scenario: * def appendList = read('../utils/append-list.js') * def arr = [{a: 'a'}, {b: 'b'}, {c: 'c'}] * def arr1 = [{a: 'a'}, {b: 'b'}, {c: 'c'}] * def arr2 = appendList([arr, arr1]) * print 'arr2', arr2 * def xx = { aa: '#(arr2)' } * print 'xx', xx * copy yy =

Karate: How can I add scenario id to the logging config?

徘徊边缘 提交于 2019-12-06 06:31:06
We are using the logging config from here and we want to add scenario id to the pattern. I was trying to find out the answer in the documentation or on the internet but I didn't find anything about how to pass a variable (some data) from Java to logback-test.xml In logback-test.xml we have something like this: <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> And we want to have something like this: <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg - %scenarioId %n</pattern> I am not aware of any way to do that in log4j / logback. If you don't find