Service Virtualization

 View Only
  • 1.  Embed virtual services in code using SV as Code

    Broadcom Employee
    Posted May 17, 2019 05:14 PM

    As more organizations and teams embrace Continuous Testing, Developers are expected to do reliable, repeatable testing of code along with development. This ensures that they identify issues early and fix them to avoid delays later on in the cycles. 


    Using CA Service virtualization enables developers to have a predictable environment / services for them to run their unit tests without having to hard-code responses. However, developers may prefer to use their IDE than to use a separate interface for these activities.


                      With Service virtualization 10.5 release, we are providing a new solution called 'Service Virtualization as Code' or SV as Code. This solution provides Java annotations that can be used in Junit tests to deploy virtual services before starting the tests. These Java annotations help embed virtual services in the code. This enables developers to write code to deploy virtual services to VSE directly from code and use it in the Junit Tests.


    Below are some of the features of the solution.

    • Create and Deploy a Virtual Service before a test
    • Create and Deploy a Virtual Service before any test from the class
    • Create and Deploy multiple Virtual Services before a test
    • Create and Deploy with vrs
    • Create and Deploy with rr-pair
    • Create and Deploy with vsm
    • Parameterized DevTest Virtual Service Annotation
    • Generate RR Pairs Utility


    This solution can be downloaded from -


    Pre-requisites for the solution

    1. DevTest server should be up and running and can be installed locally or on remote server.
    2. Need to setup registry url and VSE name through Java annotation @DevTestVirtualServer. These parameters will be used to build and deploy virtual services.


    The annotations use DevTest REST API (DevTest Invoke 2) and is compatible with DevTest versions 8.0 to 10.5.


    How do we get started?

    Getting started is pretty easy. Just add the below repository and dependency to the pom file of your maven project.

    Repository to be added




    Dependency to be added



    We have also provided a sample project 'lisabank-demo' in the url (download that you can look at to understand the configuration.


    An example of how to use the annotations is as as given below.


    DevTestVirtualServer annotation lets you define the registryHost (local by default), VSE name (VSE by default), username (svpower by default) and password (svpower by default). 


    The VirtualServices rule defined will handle the SV-as-Code annotations during the Junit lifecycle. 


    The next annotation DevTestVirtualService which needs to be added above each test definition, lets you define the virtual service by providing the serviceName, basePath for the service, port for the service, working folder (which is the folder where rr pairs, vrs file, vsm file etc. are present), requestDataProtocol (defines the data protocol to be used to process transactions).


    In addition to defining virtual services at test level, they can be defined at a class level, which will be deployed once at class level. That will use a ClassRule named VirtualServiceClassScopeRule as shown below. This will let us defined DevTestVirtualService annotation outside the class as shown below. 



    Learn more about the solution and download the same here -

    Look forward for more blogs and videos on the solution.

  • 2.  Re: Embed virtual services in code using SV as Code

    Broadcom Employee
    Posted May 24, 2019 07:51 AM

    Thanks for putting this together Surya. Waiting for the video on this.

  • 3.  RE: Embed virtual services in code using SV as Code

    Posted Sep 01, 2020 07:06 PM
      |   view attached
    Hi, Surya Anil Kumar Suravarapu,

    We are following the step-by-step that you described and after some changes to reflect our environment (Registry connection server and its port), we are receiving the following error, as shown below:

    Please, could you help us with this? I am attaching the Junit error in a txt file.


    Raphael Santos.


    JUnit_Error.txt   3 KB 1 version