karate

Can we pass the excel file or .csv file as a table input in karate feature file

倖福魔咒の 提交于 2019-12-11 09:43:25
问题 In Karate, we are parameterizing with the below values. Do we have any option of passing the table as external file in karate. And table tablename | name | age | id | | abc | 02 | 01 | | def | 03 | 02 | And def values = { "name": '(#name)', "age": '(#age)', "id" : '(#id)' } Expecting below in karate framework. And table <tablefile.xls> And def values = { "name": '(#name)', "age": '(#age)', "id" : '(#id)' } 回答1: There are multiple ways, the most recommended is to use JSON for maintaining test

How to separate table from .feature file (karate framework)

回眸只為那壹抹淺笑 提交于 2019-12-11 09:29:27
问题 Here is a simple example: Scenario: Table example * table dogs | name | age | | 'Charlie' | 2 | | 'Jack' | 4 | | 'Rock' | 9 | * match dogs == [{name: 'Charlie', age: 2}, {name: 'Jack', age: 4}, {name: 'Rock', age: 9}] Is it possible to move table to another file, and just import it? If yes, how exactly? Thanks in advance 回答1: For this use case I recommend using JSON instead of a table and it will import nicely and have the advantage of being editable by most IDE-s etc. * def dogs = read('dogs

Karate API, How do I match 2 different responses

笑着哭i 提交于 2019-12-11 09:28:59
问题 I get 2 different responses from an endpoint depending on it's state and either one of them is fine. first response: {"available":'#boolean',"collection":'#boolean'} second response: {"code": "#string","message": "#string"} I'm trying the following but it's not working: def firstSchema = {"available":'#boolean',"collection":'#boolean'} def secondSchema = {"code": "#string","message": "#string"} match response contains any (firstSchema, secondSchema) Any ideas how to best get this working so

Creating common test data for multiple feature files

浪子不回头ぞ 提交于 2019-12-11 09:02:44
问题 My requirement is as follows: I have a couple of .feature files. I want to create test data that would be common to all of these feature files. Once the test data is created the scenarios will be run from the feature files. I also want some info back after the test data is created. eg., ids of the data that i have created. So i can use this info to call the api's, add in payloads in my scenarios. I think we could do this by: 1. Creating a junit java file. I define a static method with

Run a single scenario in karate

馋奶兔 提交于 2019-12-11 09:01:30
问题 To test a specific feature in karate i run this command: mvn test -Dkarate.options="classpath:myfeature.feature" there is a way to run a single scenario defined into a feature? Thanks, Lorenzo 回答1: Yes, you can via tags: https://github.com/intuit/karate#tags Also note that you can run a scenario by name, for e.g. if the name is "first": mvn test -Dkarate.options="classpath:myfeature.feature --name ^first$" And if you use IntelliJ - you can right click and do the above. 来源: https:/

Karate- Need help to assert a single dimension array for date range

一个人想着一个人 提交于 2019-12-11 09:01:23
问题 I am trying to assert the values inside a single dimensional array. I have tried using match but it looks like the date ranges cannot be asserted. Below is the object array: [ "2019-04-24T17:41:28", "2019-04-24T17:41:27.975", "2019-04-24T17:41:27.954", "2019-04-24T17:41:27.93", "2019-04-24T17:41:27.907", "2019-04-24T17:41:27.886", "2019-04-24T17:41:27.862", "2019-04-24T17:41:27.84", "2019-04-24T17:41:27.816", "2019-04-24T17:41:27.792" ] I am trying to assert each values between the following

How to send dynamic multipart data request

别说谁变了你拦得住时间么 提交于 2019-12-11 08:44:13
问题 Below lists shows different dynamic multipart requests Request_1 Given url appServer And path '/integration/rest/application/WmSOAPProvider' * configure charset = null Given multipart file properties = { read: 'classpath:ic/feature/soap/TestData/soapInputWSDLData.json', filename: 'blob', contentType: 'application/json' } Given multipart file wsdlFiles = { read: '#(wsdlFilesPath)', filename: '#(wsdlFilename1)', contentType: 'application/xml' } And header Content-Type = 'multipart/form-data'

Call to java script code returning the ASCII encoding for ':' separating key and value of returned object

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 08:06:19
问题 I making an api request using karate where one of the api request params takes a filter condition (which is a java script object). I am using a literal notation to create a java script object as shown below. This code is in a separate filter.js file. function() { var params = { val1:[], val2:[] }; return params; } Now i call the above .js file in the karate scenario as below: Scenario: Test Given path 'filtertest/' * param filter = call read('classpath:feature/common/filter/filter.js') When

How to resolve error 415 Unsupported Media Type when Content-Type is correctly set

岁酱吖の 提交于 2019-12-11 07:58:24
问题 I have a simple POST request that requires a json Content-Type header and a body like { oneNbr: "2016004444", twoCode: "@@@", threeNbr: "STD PACK", sheetTitle: "010000", codeType: "AF14" } When I run this in Postman, it runs as expected, returning 200 status and the expected response. Here's the same script in Karate: Scenario: Sample test * def payload = """ { oneNbr: "2016004444", twoCode: "@@@", threeNbr: "STD PACK", sheetTitle: "010000", codeType: "AF14" } """ Given path '/my_end_point

How to integrate Allure Report in karate API automation project

谁都会走 提交于 2019-12-11 07:54:59
问题 We are using Karate heavily for various projects and though the report generated using karate Reports are more than anyone would need. I am still interested in getting Allure integrated in the mix. Added allure-junit4 dependency and added allure listener <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.20</version> <configuration> <argLine> -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}