Service Virtualization

  • 1.  how to create and call Methods/functions in JavaScript steps

    Posted Jun 09, 2017 08:57 AM

    HI All,

     

    We need to parse the response XML and capture all tag values and comparing with expected values and then updating the values/result in an Excel file.

     

    For that we have used JavaScript steps but the code maintenance seems difficult since we have written the code for all capture/validation/write in Excel in the single stretch.

     

    So if we get some guidance/help to create and reuse the methods by calling with parameter would make our task easy.

     

    Please help us on this.

     

    Thanks in Advance.

     

    Regards,

    Ram



  • 2.  Re: how to create and call Methods/functions in JavaScript steps
    Best Answer

    Posted Jun 12, 2017 08:01 AM

    Hi Ram2010mech,

     

    Firstly if you want to just compare the all xml tag values you can simply use a xml comparison assertion.

    If by any means that doesn't solve your problem, then 

     

    you can create functions for individual tasks and call the according. creating functions in a java script step is more over similar with

     

    example:

    add( int a, int b)
    {
    return a+b;
    }

    sub( int a, int b)
    {
    return a-b;
    }

    return add(5,15);

     

    You can also write separate Java scripts steps or create sub processes by providing input parameters.

     

    for more info on subprocess refer below

    https://docops.ca.com/devtest-solutions/10-1/en/using/using-ca-application-test/using-devtest-workstation-with-ca-application-test/building-test-cases/building-subprocesses

     

    Thanks,

    Venkatesh



  • 3.  Re: how to create and call Methods/functions in JavaScript steps

    Posted Jun 13, 2017 07:49 AM

    Thanks Venkatesh....

     

    let me try and confirm.

     

    Thanks again