Below is my sample one JSON
file, named as multiple.json
and I have given the sample structure of my json file.
{
"sample_key":[{"name":"John","salary":"10000","age":"25"}],
"another_key":[{"author":"Scott","publication":"Pearson","year":"2019"}]
}
I have single feature file which has two Scenario Outline
. This file is reading JSON
object from multiple.json
file which contains different JSON
object separated by key value pair. And I want to pass the data in request payload
which is sample_key
and another_key
in the below feature file.
My Sample.feature
file:
Background:
* def kittens = read('../json/multiple.json')
Scenario Outline: Create Sample Name Record
Given url url
And request { sample_key:'<sample_key>'} // Here, I have question..
When method POST
Then status 200
* def output = response
* print output
Examples:
|kittens|
Scenario Outline: Create Sample Author Record
Given url url
And request { another_key:'<another_key>'} // Here, I have question..
When method POST
Then status 200
* def output = response
* print output
Examples:
|kittens|
However, it is working only with below JSON
with scenario
.(Here, I do not have added JSON object in array
)
{
"sample_key":{"name":"John","salary":"10000","age":"25"},
"another_key":{"author":"Scott","publication":"Pearson","year":"2019"}
}
But it's not working when I give the JSON object in array
(as mentioned at the top of question)
I want to pass multiple records in a single sample_key
which I want to run it in a single scenario
.
So, how can I pass sample_key in Scenario Outline: Create Sample Name Record
?
Kindly suggest me. Thank you !!