Ask a Question

How to get test step response in readyAPI using Java?

SOLVED
arunbharath
Contributor

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.

18 REPLIES 18

Hi nmrao. Thanks for help. I tried with WsdlProjectPro. Now I'm getting null pointer exception while executing, Please find my code

public void test() {

		final String testProjectFileNameStr = "C:\\Users\\akrishnan\\git\\automation\\";

		ProxySelector.getDefault();

		final WsdlProjectPro project = new WsdlProjectPro(testProjectFileNameStr);
		final String name = project.getName();
		System.out.println(name);

		final WsdlTestSuitePro testSuite = (WsdlTestSuitePro) project.getTestSuiteByName("InitiateTransfer");

		final int numOfTestCases = testSuite.getTestCaseCount();

		System.out.println("Number Of Test Cases: " + numOfTestCases);

		for (int i = 0; i < numOfTestCases; i++) {

			testCase = (WsdlTestCasePro) testSuite.getTestCaseAt(i);

			final String test = testCase.getName();

			System.out.println(test);

			final int numOfTestSteps = testCase.getTestStepCount();

			System.out.println("Number of Test Steps: " + numOfTestSteps);

			for (int j = 0; j < numOfTestSteps; j++) {
				// String reasonStr = "";
				final WsdlTestStep testStep = testCase.getTestStepAt(j);

				final String testStepNameStr = testStep.getName();

				final int countSteps = j + 1;
				System.out.println(countSteps);
				// KSU.testStepsOut(countSteps, testStepNameStr);

				final WsdlTestCaseRunner testRunner = new WsdlTestCaseRunner(testCase, null);

				soapResult = testRunner.runTestStepByName(testStepNameStr);

				final Status result = testRunner.getStatus();
				final String resultStr = result.toString();
				System.out.println(resultStr);

			}
		}

	}

In the above code snippet, I'm getting null pointer in final WsdlTestCaseRunner testRunner = new WsdlTestCaseRunner(testCase, null);

 

Can we use WsdlTestCaseRunner to run the case or we have to use something else specifically for soapui-pro?

 

FAILED: test
java.lang.NullPointerException
	at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.checkSaveMetrics(WsdlTestCaseRunner.java:84)
	at com.eviware.soapui.impl.wsdl.testcase.WsdlTestCaseRunner.<init>(WsdlTestCaseRunner.java:36)
	at com.interac.oas.payments.SoapRunner.test(SoapRunner.java:93)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:108)
	at org.testng.internal.Invoker.invokeMethod(Invoker.java:661)
	at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:869)
	at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:1193)
	at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:126)
	at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
	at org.testng.TestRunner.privateRun(TestRunner.java:744)
	at org.testng.TestRunner.run(TestRunner.java:602)
	at org.testng.SuiteRunner.runTest(SuiteRunner.java:380)
	at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:375)
	at org.testng.SuiteRunner.privateRun(SuiteRunner.java:340)
	at org.testng.SuiteRunner.run(SuiteRunner.java:289)
	at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
	at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
	at org.testng.TestNG.runSuitesSequentially(TestNG.java:1301)
	at org.testng.TestNG.runSuitesLocally(TestNG.java:1226)
	at org.testng.TestNG.runSuites(TestNG.java:1144)
	at org.testng.TestNG.run(TestNG.java:1115)
	at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:115)
	at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
	at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

Use pro api


Regards,
Rao.

Hi nmao.

 

    I'm not able to find pro api equalent to below steps. I checked Pro API guide, but I couldn't find anything. can you help me on this?

final WsdlTestCaseRunner testRunner = new WsdlTestCaseRunner(testCase, null);

				soapResult = testRunner.runTestStepByName(testStepNameStr);

Will check.

Even in the script, didn't happen to notice the integration between test step and selenium. Would you please point?


Regards,
Rao.

Hi nmrao. I wrote a separate class for the selenium and test step integration part. Here I'm trying to run readyAPI test cases and would like to receive the response of the each test step, I will pass those response as a JSON paramater to another class where I work on selenium with test data response as an input.

Any inputs on my issue? 

You better open a support case to find out the same.


Regards,
Rao.

have you tried ant because one of my colleage is also trying to do the same, and as per him he will create the project in soapui and execute the project via ant and ant will store the response into one notepad file from where he will read the response and validate on UI.

 

If you need more info then do let me know i will connect with him and will try to help you how he is doing.

 


Click "Accept as Solution" if my answer has helped,
Remember to give "Kudos" 🙂 ↓↓↓↓↓



Thanks and Regards,
Himanshu Tayal
cancel
Showing results for 
Search instead for 
Did you mean: