Forum Discussion

kanumallakishor's avatar
kanumallakishor
Occasional Visitor
7 years ago

Changing Custom Properties while Runnig TestSuite From Java

Hi Team,

 

I am running SOAP UI Project from standalone java project which has one  TestSuite with 3 Test cases in which the data is dynamically populated.

When i run the test cases from SOAP UI Tool i added a custom property and assigned the value.

How to do the same while i am running from My Java Code.I tried to get the Project Properties and Set but it is not working.

Please let us know the best option to achieve the same , below is the code snippet.

 

System.setProperty("soapui.home", "C:\\Program Files\\SmartBear\\ReadyAPI-2.2.0");
// Create a test runner object
SoapUIProTestCaseRunner runner = new SoapUIProTestCaseRunner();
// Specify the path to the project file
runner.setProjectFile("C:///SoapUI.xml");
// Specify the test suite to run
runner.setTestSuite("TestSuite 1");
// String a[] ={"currencyCode=xxx"};
// runner.setProjectProperties(a);

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

// runner.setEnableUI(true);

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

runner.setJUnitReport(true);

runner.setJUnitReportWithProperties(true);
// Start the test run
runner.run();


 

 

1 Reply

  • JHunt's avatar
    JHunt
    Community Hero

    I notice you're using a SoapUIProTestCaseRunner. I couldn't find documentation about it online (Google's link to www.soapui.org/apidocs/pro/com/eviware/soapui/SoapUIProTestCaseRunner.html wouldn't load).

     

    Here's how I'd do it in the SoapUI Open Source world - it might give you some things to try:

     

    import com.eviware.soapui.impl.wsdl.WsdlProject
    import com.eviware.soapui.support.types.StringToObjectMap

    WsdlProject project = new WsdlProject("/project.xml")
    project.setPropertyValue("currencyCode", "xxx")

    boolean async = false
    StringToObjectMap context = new StringToObjectMap()
    project.testSuites["TestSuite 1"].testCases["TESTCASE1"].run(context, async)