Service Virtualization

Expand all | Collapse all

Scripted Assertion - global to the project

Jump to Best Answer
  • 1.  Scripted Assertion - global to the project

    Posted 04-25-2018 10:21 AM

    Hi Everyone,

     

    I have a scripted assertion step that is common to all the models within the project.

    Every time I create a new service, I'm adding this scripted assertion step manually to all the model.

    Sometimes, I make some changes to the script, I need to manually update the changes to ALL the models (vsm) in the project.

     

    Is there a way to make this scripted assertion step global to the entire project (changes at one place and it applies the changes to all the vsm's)

     

    Appreciate your help/advise.

     

    Thanks,

    John



  • 2.  Re: Scripted Assertion - global to the project
    Best Answer

    Posted 04-25-2018 02:16 PM

    Hi John,

     

    The most elegant solution would be to create a custom assertion using the SDK:

     

    https://docops.ca.com/devtest-solutions/10-3/en/using/using-the-sdk/extending-assertions

     

    That will put all of your logic into a jar file - no need to copy/paste a script.  Any changes you make to the code would automatically update all of your assertion instances as soon as the new jar is deployed.

     

    Alternatively, if you're not comfortable using the DevTest API, you can create a Java method outside of the SDK framework.  If you put it in a jar and drop it into hotDeploy, you can invoke the method from anywhere.  You'd still use a scripted assertion, but it'd simply look like this:

     

       return com.mycompany.devtest.MyCoolAssertion();

     

    You'd get the same benefits as extending the DevTest API - it's just not quite as pretty.

     

    --Mike



  • 3.  Re: Scripted Assertion - global to the project

    Posted 04-26-2018 01:11 AM

    wow, thats so cool idea.

    Thank you, Mike

     

    -John



  • 4.  Re: Scripted Assertion - global to the project

    Posted 04-26-2018 02:46 AM

    What Mike has suggested is a perfect way to do it, but I think there is an easy workaround for this. 

    You can do this by creating a "sub-process".

     

    In the sub-process add a "Do-Nothing-Step", and add your scripted assertion to your do-nothing-step, now, all you need to do is just add this sub-process to your newly generated models every time you create a new service.

     

    The only single place where you need to change your script is in that sub-process.

     

    Hope this helps.

     

    Correct me if I have missed something Mike_Gavaghan



  • 5.  Re: Scripted Assertion - global to the project

    Posted 05-08-2018 10:06 AM

    Thank you, Shubam..