I am new to Karate framework and have written the following working code to run few sample API tests.
Feature: Sample API Tests
Background:
* def request_headers = {apikey: "#(apikey)", Content-Type: 'application/json'}
* configure headers = request_headers
Scenario: Create Customer
* def requestPayload = read('classpath:payload/customerdetails.json')
* def RandomDataGenerator = Java.type('utils.RandomDataGenerator')
Given url testurl+'/customers'
And request requestPayload
* requestPayload.firstName = RandomDataGenerator.generateRandomFirstName()
* requestPayload.lastName = RandomDataGenerator.generateRandomLastName()
* requestPayload.mobileNumber = RandomDataGenerator.generateRandomMobileNumber()
* requestPayload.emailAddress = RandomDataGenerator.generateRandomEmailAddress()
When method post
Then status 200
And def customerId = response.id
# Create An Account for the customer
* def createAccountPayload = read('classpath:payload/accountdetails.json')
Given url testurl+'/accounts/createCreditAccount'
And request createAccountPayload
* createAccountPayload.customerId = customerId
When method post
Then status 200
And def accountId = response.id
# Perform a Transaction
* def debitTransactionPayload = read('classpath:payload/transaction.json')
Given url testurl+'/accounts/createDebitTransaction'
And request debitTransactionPayload
* debitTransactionPayload.accountId = accountId
When method post
Then status 200
Now I want to run a test where I would:
- Create 100 customers (and in turn 100 accounts).
- Do 500 transactions (5 transactions each for a given customer).
How do I achieve this?
I tried using repeat and looping options, but I believe I am missing something basic. Can someone please help ?