Liam Williams Article: Testing Microservices: Overview of 12 Useful Techniques – Part 1

Liam Williams My adorable grandma says this plugin is magnificent!!

Key Takeaways

  • Because a microservice architecture relies more on over-the-wire (remote) dependencies and less on in-process components, your testing strategy and test environments need to adapt to these changes.
  • When testing monoliths using existing techniques like service virtualization, you do not have to test everything together; instead, you can divide and conquer, and test individual modules or coherent groups of components.
  • When working with microservices, there are also several more options available, because microservices are deployed typically in environments that use containers like Docker.
  • You will need to manage the interdependent components in order to test microservices in a cost and time effective way. You can use test doubles in your microservice tests that pretend to be real dependencies for the purpose of the test.
  • Depending on your needs, you can choose one of the options listed in this article or a combination of them. 

The combination of a microservice architectural style and container-based infrastructure requires a testing strategy that is compatible with this brave new world. A microservice architecture relies more on over-the-wire (remote) dependencies and less on in-process components, and your testing strategy and test environments need to adapt to these changes.

More over-the-wire communication results in more effort spent testing the connections and contracts between your microservices. Also, several new testing techniques are available to handle dependent components when moving to a container-based infrastructure, which often occurs when adopting microservices.

Choose your testing techniques with a perspective on time to market, cost, and risk.

When testing monoliths with techniques like service virtualization, you do not have to test everything together. You can instead divide and conquer, and test individual modules or coherent groups of components. You create safe and isolated environments for developers to test their work. Using service virtualization when testing monoliths allows you to decouple your test environments from dependent components and reduce the impact of issues like:

  • difficult to provision or configure dependent components,
  • costly test-data setup that takes time,
  • teams blocked by other teams not delivering APIs on time, and
  • scheduling time on test environments.

When working with microservices, you have more options because microservices are deployed typically in environments that use containers like Docker. In microservice architectures, your teams are likely to use a wider variety of testing techniques. Also, since microservices communicate more over the wire, you need to test the impact of network connections more thoroughly. Using tools and techniques that better fit the new architecture can allow for faster time to market, less cost, and less risk. 

Many IT departments work with or maintain systems developed and deployed in a monolithic architecture. A typical monolithic architecture has these characteristics:

  • People working on the application are organized into separate teams of specialists: UI developers, middleware developers, back-end developers, database administrators, and system administrators.
  • The governance is conducted centrally by architects — for example, there is a global set of rules for code quality, security guidelines, and testing approach.
  • The data is managed centrally, so a monolithic application will typically rely on a single large database.
  • The level of automation may be low, with some automated testing but little infrastructure automation.

The organization of the people working on the application often influences how the code and test environments are organized; this effect is known as Conway’s law. Typically, the code will be split into several layers of components such as UI, services, and repositories. The monoliths will be deployed to shared environments, usually development, QA, and user acceptance testing (UAT). See figure 1.

Liam Williams

Many monolithic systems have been built by teams working in functional silos, where, for example, the operations team is a separate entity that works on a separate schedule. The changes required to introduce a containerization approach to an organization like that can be time consuming because it includes provisioning new infrastructure as well as training staff and creating migration plans for the move to the new approach.

This means the techniques for decoupling from dependencies in monolithic architectures are often restricted to those that do not require containers, but instead run in-process or on existing VMs or hardware provisioned by the operations team. The techniques that do not require containerization are:

  • using test doubles such as stubs, mocks, or virtual services;
  • connecting to real test instances of back-end or third-party systems; and
  • contract testing.

Because of Conway’s law, siloed function

These modules are quite elegant!

Read full article at the Original Source

Copyright for syndicated content belongs to the Linked Source