Forum Discussion

Devakara's avatar
Devakara
Occasional Contributor
15 years ago

Invoke a test step from java

Hi Ole,

How do we invoke a particular Test Step of a soapUI project XML from java?

I have learnt how a Test Case needs to be invoked from java. But couldn't figure out how to get hold of TestCaseRunContext, for running a particular test step.

Please look into this and let me know the solution.

Thanks,
Devakara.
  • kamahade's avatar
    kamahade
    Regular Contributor
    Hi Dev,

    check if following will help you..

    def myrunner = new com.eviware.soapui.SoapUIProTestCaseRunner();
    myrunner.runRunner();

  • Devakara's avatar
    Devakara
    Occasional Contributor
    Thanks for the reply kamahade.

    I have obtained TestCaseRunner using SoapUITestCaseRunner as below:

    SoapUITestCaseRunner runner = new SoapUITestCaseRunner();
    runner.setProjectFile(projectPath);


    But my question is how do I get the current TestCaseRunContext, which allows me to run a particular test step of soapUI project XML stored at <projectPath>.

    Or else let me know if there is way of directly running a particular Test Step of a soapUI project XML using runner object, in java.

    Thanks,
    Devakara.
  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    Hi!

    try the following from code:

    WsdlProject project = new WsdlProject( "<path to your project>" )
    WsdlTestCase testCase = project.getTestSuiteByName( "..." ).getTestCaseByName( "... " )
    WsdlTestStep testStep = testCase.getTestStepByName( "... " )

    WsdlTestCaseRunner runner = new WsdlTestCaseRunner( testCase, new StringToObjectMap() )
    runner.runTestStep( testStep )

    Does that work?

    regards,

    /Ole
    eviware.com
  • Devakara's avatar
    Devakara
    Occasional Contributor
    Hi Ole,

    Its working! Thank you very much.

    I shall write a detailed post about this in my blog soon.

    Thanks,
    Devakara.