Is this possible to use dataGenerator inside Json?

Viewed 20

Have a little problem. I have a feature postUser with request body, which I provide inside this feature. Body doens't have unique data, it filled manually. I know that I can read this requestBody from requestBody.json but I dont know how to connect data generator to this json and even if this a possible. So, my json looks like this

{
"first_name": "test",
"last_name": "user",
"email": "test@sjdas.com",
"phone_number": "12341415",
"image": "",
"status": "INACTIVE",
}

And I want to have dataGenerator inside this json like this

{
"first_name": "#(userName)",
"last_name": "#(userLastName)",
"email": "#(userEmail)",
"phone_number": "#(userPhoneNumber)",
"image": "",
"status": "INACTIVE",
}

Is this possible to have the next scenario if yes, how can I do this?

* path 'user'
And request requestBody
When method Post
Then response 200

P.S. I'm a newbie in Java, so I don't know how to resolve this(

1 Answers

Found solution. We can't use a data generator inside of the JSON. But we can set the randomly generated value into a JSON file before making the POST request. All of this should be described inside feature and also JavaFaker should be connected.

Related