I have Karate scenario defined as below
Feature: Random Users
Background:
* url 'https://askuser.me'
@get-user
Scenario: Get Random User data
Given path 'api'
When method get
Then status 200
* string json = response
* def Util = Java.type('com.example.mobiletest.utils.TestUtils')
* def SaveResponse = Util.writeToJSONFile(json,'randomuser.json')
And is Corresponding Runner class defined as below:
public class RandomUserRunner {
@Karate.Test
public Karate testRandomUserRunner(){
return Karate.run("RandomUser").relativeTo(getClass());
}
}
I want to execute testRandomUSerRunner() programatically from other java function, how do I do that (reason this is, karate scenario fetches response and saves in json file, other method in java want to reuses these steps)
I tried to call as below but it didnt work:
RandomUserRunner runner = new RandomUserRunner();
runner.testRandomUserRunner();
Anyhelp or pointers would be really appreciated.