Service Virtualization

Expand all | Collapse all

Accessing output parameters from subprocess in beanshell script

Jump to Best Answer
  • 1.  Accessing output parameters from subprocess in beanshell script

    Posted 06-07-2018 03:40 PM

    How can I access output parameters from subprocess in beanshell script?

     

    Step 1 : execute Subprocess : Output parameter: FolderName (Checked)

    Step 2: execute Script: testExec.getStateValue("FolderName") returns null

     

    is there a different way to deal with subprocess parameters?



  • 2.  Re: Accessing output parameters from subprocess in beanshell script

    Posted 06-07-2018 06:39 PM

    What version of DevTest are you using?  I will try to see how we can get the output parameters 



  • 3.  Re: Accessing output parameters from subprocess in beanshell script

    Posted 06-07-2018 06:41 PM

    10.1 



  • 4.  Re: Accessing output parameters from subprocess in beanshell script
    Best Answer

    Posted 06-08-2018 08:36 AM

    Can you show us some screen shots to help us.

     

    In particular, I would like to see the Parameters To and Results From setup in the Main test and the input and output parameters as shown in the subprocess.  "FolderName" should be defined in both places.

        

    The following simple example works under 10.1 on my machine:

    Set up a work field simply parses a fake XML payload into a property fl_primeXml.

    The main test passes the input fl_primeXml parameter to the subprocess and expects a sub_CountOfOccurs property back. 

    The SubProcess only has one step containing an XPath Filter.

    Similarly, the subprocess identifies the input parameter fl_primeXml and sub_CountOfOccurs is shown as an output property.  

     

      

    When we run this in ITR we see.

    The Print Pre-Step simply invokes a script to see if the value exists or not.

    _logger.info( "The value of the counter before calling subprocess is: {}",
      testExec.getStateString("sub_CountOfOccurs", "This value does not exist") ); 

     

     

    And this is confirmed by the properties panel in ITR right before the subProcess is called:

    But what I would be interested to see in your ITR view are the properties right after the call to the subprocess. In my example, the property created by the subprocess shows up in the response.

    And the JSR step that follows is also able to access the property and print its value in the log file.

    Attachment(s)

    zip
    Sub.tst.zip   1K 1 version
    zip
    Prime.tst.zip   1K 1 version


  • 5.  Re: Accessing output parameters from subprocess in beanshell script

    Posted 06-08-2018 09:39 AM

    In the Main Test Case-->Subprocess step, if you have selected the output parameter in Resultset Properties (3rd screenshot from Joel-->sub_CountOfOccurs) then the output parameter is available to the Main test case and beanshell should have access to it as long as it is used after the Subprocess step.