Booking confirm is one of the reusable file in automation script which runs the api endpoint and returns the json payload, which is large payload. When it get execute first time its very fast execution and in main feature file doing lots of validation. And afer some other operation calling the booking confirm reusable file to validate the amend details. but it takes long. not sure why? and thrid time even taks longer than the second time. I thought the values could be overriding in the contex. Can someone help on this, to improve perform of karate automation script, when we call reusable file multiple time from the mainfeature
main.feature
* def bookingConfirmationDetails = call read('classpath:Opera/ReusableFiles/Features/ReusableBookingConfirmation.feature') {basketReference: '#(reference)', country: '#(countryLowerCase)', language: <languageBooking>, bookingChannel: 'PI'}
ReusableBookingConfirmation.feture ( reusable file)
@ignore
Feature: Booking Confirmation
Background:
* url Endpoint
# input parameters xApiKey, basketReference, language, country, queryFileName, statusCode
* def basketReference = karate.get(‘reference’, null)
* def language = karate.get(‘language’, null)
* def country = karate.get(‘country’, null)
* def bookingChannel = karate.get(‘bookingChannel’, ”)
* def queryFileName = karate.get(‘queryFile’, ‘BookingConfirmation.graphql’)
* def statusCode = karate.get(‘statusCode’, 200)
Scenario: Booking Confirmation – Experience API
* def query = read(‘classpath:ReusableFiles/QueryPayload/BookingConfirmation/’ + queryFileName)
* def variables = {basketReference: ‘#(basketReference)’, country: ‘#(country)’, language: ‘#(language)’, bookingChannel: ‘#(bookingChannel)’}
Given request { query: ‘#(query)’, variables: ‘#(variables)’ }
And header X-WHIT-API-KEY = EncryptionUtils.decode(ENCODED_X_WHIT_API_KEY)
When method post
Then assert responseStatus == statusCode
Note: Endpoint & ENCODED_X_WHIT_API_KEY are defined in karate-config.js file
Please look at hooks such as callonce
which should solve this problem.
3