Isaac Sacolick
Contributing writer

The benefits of API and service virtualization

analysis
Jul 12, 20217 mins
APIsApp TestingSoftware Development

Virtualization of APIs and application services supports robust and earlier testing, an important part of application modernization.

software development / application testing / tools in hand amid abstract code mapping
Credit: Sorayut / MF3D / Getty Images

If you’re developing applications that connect to multiple microservices, software-as-a-service (SaaS) APIs, legacy systems, and other third-party services, creating a robust testing environment can be tricky. For example, suppose one API you are validating is to a microservice your team developed. In that case, you probably have devops capabilities, including continuous integration and continuous delivery (CI/CD), infrastructure as code, and tools to create test data sets to enable a testing environment for this service. However, even with these capabilities, it can become costly to spin up multiple testing services when teams develop many cloud-native applications and microservices.

If it’s a third-party API, SaaS, or data stream, you may have to rely on that service’s testing infrastructure and capabilities. Although these test environments should support the production system’s functionality, they may not have a complete data set, and putting them under load to support performance testing may violate the terms of service or be expensive.

Service and API virtualization platforms aim to address these complexities by creating and simulating API and service endpoints. Instead of spinning up a testing environment, the service virtualization platform serves as the endpoints for testing downstream applications and composite services, and it responds to a connecting application’s or service’s requests and transactions.

If you’re working with only a few APIs, API mocking may be a good enough practice for simulating endpoints, and tools like Mockito, JMock, or WireMock are Java options. But once you have many development teams, growing APIs, or complex test data sets, a more scalable approach like service virtualization is needed. Furthermore, if you are testing apps that process credit cards, connect to bill paying services, or perform other complex transactions, then service virtualization platforms enable validation against a wider breadth of user experiences and error scenarios.

I spoke with Anna Ramadoss, a cloud engineer in financial services, about using a service virtualization platform. She says, “Service virtualization, once mainstream on the teams, thins the line between the main and dependent systems. Updates are immediate, and the delivery timelines get way quicker. The result is a well-crafted system with quicker updates to the market. It can also reduce infrastructure needs and costs.”

How service virtualization enables shift-left testing

Many organizations are looking to shift-left their testing efforts to identify and resolve issues faster. But what happens when a testing environment isn’t available for dependent services?

It’s natural for developers to circumvent blocks and impediments to their engineering efforts. When developing applications, should the developers wait for an API’s testing infrastructure and capabilities, or are they more likely to push this testing until later in the development process? Even more problematic, will developers make assumptions on an API’s behaviors and then be forced to resolve defects later in the development process, or worse, when they are found in production?

Instituting a service virtualization platform and requiring service virtualization as a development standard has many benefits, especially for teams that require extensive testing capabilities against many APIs. Here are several advantages to using a service virtualization platform to help shift-left testing:

  • Service virtualization is a natural extension of developing unit tests and instituting continuous testing for microservices. As part of the development process, developers or quality assurance engineers should configure endpoints in the service virtualization platform that simulate the API’s responses. All the developers can use these endpoints when building downstream apps and services.
  • Service virtualization layers simplify testing against multiple versions of an API by exposing endpoints for all supported versions. When testing against new API versions, developers can create tests that compare the responses of the latest version with older ones. This kind of A/B testing can be particularly useful for validating the downstream impacts of new releases of machine learning models and predictive analytics.
  • Service virtualizations can be bundled with test data sets and used to validate transactions. Once developers complete a testing scenario, they can refresh the endpoint back to the original test data set and repeat the testing as needed.
  • When operating on a cloud, service virtualization platforms can ramp up and down capacity based on testing volume. As a result, the infrastructure can scale to handle many developers running simultaneous tests or more robust performance testing.

By solving a common testing infrastructure challenge, teams can use a service virtualization platform’s capabilities to institute new testing scenarios earlier in the development process.

Platform providers suggest other use cases. For example, SmartBear recommends that development teams use service virtualization to enhance security testing, automate different testing scenarios by message types, and support iterative designs. Parasoft recommends using service virtualization to test against malformed data responses, simulate high latency, or validate responses to larger payloads. Broadcom Service Virtualization (formally CA DevTest) advises development teams to chain tests into multistep transactions and continuously validate business workflows.

Ramadoss advises development teams to determine their testing requirements to see if API virtualization is sufficient, or if the more generalized service validation is required. For example, she says, “Service virtualization extends to TCP-based protocols to support services from credit bureaus like TransUnion, Equifax, and Experian.” Other protocols that may be needed include database (JDBC), middleware (JMS, Rabbit MQ, and others), and mainframe protocols (CICS and others).

I spoke to Shamim Ahmed, devops CTO at Broadcom, about how devops organizations use service virtualization in virtual service environments. He says, “As more organizations evolve to component architectures for their software systems, we see an increasing trend towards adoption of microservices for development and containerization for deployment. To support this trend, virtual services can be packaged and deployed in containers, instantiated on-demand, and decommissioned when no longer needed.”

How service virtualization works

Platforms have different capabilities to create service endpoints, and here are the common approaches:

  • Linking or uploading an API’s definition in Web Service Description Language (WSDL), Web Application Description Language (WADL), or OpenAPI Specification (OAS) (Swagger)
  • Recording transactions using browser plug-ins or web server proxies
  • Manually creating service definitions, which can be useful when downstream developers want to test before APIs are ready

After creating endpoints, platforms generally enable connecting to test data sources, uploading test data, or automating test data generation. Generating test data is very useful when validating forms or document uploads and processing complex transactions. It is also a more secure way to create mock data sets on personally identifiable information (PII) such as names, Social Security numbers, or credit card numbers.

Once there are service endpoints, service virtualization platforms offer development kits, IDE plug-ins, and CI/CD tool plug-ins as different ways to interface and leverage them. Development teams who target frequent deployments can improve continuous testing practices by having more API endpoints available and increasing the breadth of test data sets.

Agile development teams that use service virtualization platforms and mature continuous testing practices should consider several best practices, such as creating negative test cases and training the technical staff. Some best practices for accelerating testing cycles include defining infrastructure requirements, securing virtualized services, and updating systems regularly. Leaders should also seek tangible business benefits such as bringing new applications to production faster and reducing costs.

As more organizations modernize applications for the cloud, develop microservices, and integrate with many SaaS platforms, service virtualization is a critical platform capability to support robust and continuous testing.

Isaac Sacolick
Contributing writer

Isaac Sacolick, President of StarCIO, a digital transformation learning company, guides leaders on adopting the practices needed to lead transformational change in their organizations. He is the author of Digital Trailblazer and the Amazon bestseller Driving Digital and speaks about agile planning, devops, data science, product management, and other digital transformation best practices. Sacolick is a recognized top social CIO, a digital transformation influencer, and has over 900 articles published at InfoWorld, CIO.com, his blog Social, Agile, and Transformation, and other sites.

The opinions expressed in this blog are those of Isaac Sacolick and do not necessarily represent those of IDG Communications, Inc., its parent, subsidiary or affiliated companies.

More from this author