Forum Discussion

arunbharath's avatar
arunbharath
Contributor
5 years ago

How to get test step response in readyAPI using Java?

Hi All.

     I'm trying to execute ReadyApi test cases from Java. I'm able to execute the test case but I could figure how to retrive the response from test step using java. I need couple of fields from the response to validate externally. Can anyone help me on this? I couldn't find any tutorial or support from the internet. 

 

		try {
			// Create a test runner object
			final SoapUIProTestCaseRunner runner = new SoapUIProTestCaseRunner();

			// Specify the path to the project file
			runner.setProjectFile("C://Work//sampleproject.xml");

			// Specify the test suite to run
			runner.setTestSuite("TestSuite 1");

			// Specify the test case to run
			// It must be in the test suite specified above
			runner.setTestCase("TestCase 1");

			// Run the test
			// Command the runner to create JUnit-style report
			runner.setJUnitReport(true);

			// Command the runner to create printable report
			runner.setPrintReport(true);

			// Command the runner to open the created report
			runner.setOpenReport(true);

			// Specify the folder to save the report in
			runner.setOutputFolder("C:\\Users\\mwl\\tmp");

			// Start the test run
			runner.run();
		}
		// Handle the exception, if any
		catch (final Exception e) {
			e.printStackTrace();
		}
	}

Above is the code. I have used to execute the test cases. any help would be appreciated.

  • nmrao's avatar
    nmrao
    Champion Level 3
    When it is possible to execute the tests using testrunner.bat (.sh) utility of READYAPI_HOME/bin, what are you trying to achieve by writing java? Just trying to understand what testrunner can't do and that is achieved by your program.
    • arunbharath's avatar
      arunbharath
      Contributor

      nmrao  Thanks for you response.

      I've got a UI testing scenarios for that I need values from the API response. I used TestNG  framework with java to achieve the UI automation (I know readyAPI supports selenium,, but My case needs a lot of classes, so TestNG is better compared to readyAPI, I believe). So to achieve that, I have to run readyAPI through java and get the response values. I already worked on this by using soapUI, I'm able to achieve that. But when comes to readyAPI, I'm not getting proper documentation for java integration. Any inputs is appreciated.