cancel
Showing results for 
Search instead for 
Did you mean: 

How to run a Test case from Java and be able to set and retrieve properties and see report

Highlighted
Occasional Contributor

How to run a Test case from Java and be able to set and retrieve properties and see report

SoapUI is a great product for managing Soap and Rest messaging in the context of testing.

I want to support the use of existing and future SoapUI Pro tests within our chosen test framework - but I have an issue that is driving me crazy.  The alternative is to not use SoapUI Pro at all - which is not my objective at all.

 

I am trying to run a Test case from Java and be able to set and retrieve properties and see report output.

I see examples of some of these elements here:

https://support.smartbear.com/readyapi/docs/testing/integrations/junit.html

 

These examples seem to be out-of-date - or is that just me?

 

The link to the SoapUIProTestCaseRunner is to: https://soapui.org/apidocs/pro/com/eviware/soapui/SoapUIProTestCaseRunner.html#_ga=2.53884712.107260...

 

However the example uses: import com.smartbear.ready.cmd.runner.pro.SoapUIProTestCaseRunner;

 

SoapUIProTestCaseRunner is good to run the test case and see the report - but I cannot set the properties or retrieve the results.

 

The next description: "To have more control over integration and error reporting, run a specific test case:" seems to suggest that the same as SoapUIProTestCaseRunner but with more control is possible.  Unfortunately, this does not seem to be the case.

I can do this call: testCase.run(new PropertiesMap(), false)

. . . and the test case runs - but when a step fails - how do I find out which step or which assertion failed?

 

Also - any steps involving Pro features (e.g. reading data from Excel) fails with reason: "Cancelling due to failed test step" - but which step failed?

 

Looking through the API, I see this:

https://soapui.org/apidocs/pro/index.html?com/eviware/soapui/SoapUIProTestCaseRunner.html

 

SoapUIProTestCaseRunner seems to offer the useful runTestCase method: https://soapui.org/apidocs/pro/com/eviware/soapui/SoapUIProTestCaseRunner.html#runTestCase(com.eviwa...)

https://soapui.org/apidocs/pro/com/eviware/soapui/SoapUIProTestCaseRunner.html#runTestCase(com.eviwa...)

SoapUIProTestCaseRunner also looks to have helpful reporting methods.

 

I cannot find the SoapUIProTestCaseRunner object in the versions of SoapUI that I have (1.5; 1.6).

 

Further, I have found the use of this code:

SoapUIPro.SoapUIProCore soapuiCore = new SoapUIPro.SoapUIProCore(true, "/path/to/soapui-settings.xml");

 

Which might be helpful, but I cannot find the class SoapUIPro.SoapUIProCore - only the SoapUIProCore interface.

 

Please, can someone suggest what combination of objects/methods in current versions of SoapUI Pro can be used to both run specific test cases - giving report output - and access the properties?

I need to see the imports - my Java skills are a bit dusty and I am yet to learn how to search through Jars (something like using Oops! I think)!

Attached is my existing attempt.

Thank you

1 REPLY 1
Occasional Contributor

Re: How to run a Test case from Java and be able to set and retrieve properties and see report

I got this answer from SmartBear regarding SoapUIProTestCaseRunner:

 

Hi Vernon,

The Javadoc is out of date and was last updated for SoapUI Pro 5.1.2. It has not been updated for Ready API, and in Ready API there was a number of package name changes. SoapUIProTestCaseRunner is in the package com.smartbear.ready.cmd.runner.pro. As for generating a report you can do that by using the SoapUIProTestCaseRunner class and the associated methods such as setJunitReport(boolean), setReportFormat(String[] args), setReportName(String arg), etc. You can not change testcase, testuite, or test step properties with the SoapUIProTestCaseRunner class, you would have to change the properties by getting to the testsuite or testcase level by creating a new project object and getting down to the testcase or testsuite you want to modify properties for.

WsdlProjectPro project = new WsdlProjectPro("C:\\SoapUI\\SOAPUI Projects\\Basic-auth-test-soapui-project.xml");
List<WsdlTestSuite> testSuites = project.getTestSuiteList();
for (WsdlTestCase testCase : testCases) {
System.out.println("Running SoapUI test [" +
testCase.getName() + "]");
}

After making modifications to the properties you can use the project.save() method to save the project file to run with SoapUIProTestCaseRunner. If you do not want to run with SoapUIProTestCaseRunner and want to be able to generate reports then I would have to escalate this to development as I do not see any methods you can directly call to do that other than the ones in SoapUIProTestCaseRunner.


Regards,

 

Really SmartBear: you were saying in 2010 that you would improve the documentation!

 

New Here?
Join us and watch the welcome video:
Watch the new Interview
Top Kudoed Authors