Modal Title
CI/CD / Containers / DevOps

How Testcontainers Is Demonstrating Value as a Key CI Tool

Testcontainers is a library originally written in Java that helps developers run module-specific Docker containers while the app is being built in order to simplify integration testing.
Apr 10th, 2023 7:55am by
Featued image for: How Testcontainers Is Demonstrating Value as a Key CI Tool

When software developers are building their microservices for use inside Docker containers, it saves a great deal of time and effort for them to also test for various dependencies in parallel instead of starting from scratch after the app is done. As those dependency dots are connected, they often require changes to the app, which means doubling back and re-doing the code. And nobody likes re-doing anything.

This is where something new called Testcontainers comes to the proverbial rescue. Testcontainers is a library originally written in Java that helps developers run module-specific Docker containers while the app is being built in order to simplify integration testing. These Docker containers are lightweight, and once the tests are finished, the containers are destroyed, and developers can move on to the next project.

Modules Program

Software company AtomicJar, a pioneer in this sector, on April 5 launched its Testcontainers Official Modules program with the backing of several major vendors. Redpanda, StreamNative, Neo4j, Cockroach Labs, LocalStack, Oracle and Yugabyte were among the first to declare support for Testcontainers.

The modules catalog features more than 50 modules supporting a list of often-used technologies and provides certification, support, and maintenance of Testcontainers modules for the development community. Each community partner is committed to supporting the program as the preferred way of testing their work and to developing with other partners locally.

“Testcontainers allow developers to test and develop their code against the real dependencies they will use when the app goes live for use,” Eli Aleyner, co-founder of AtomicJar, told The New Stack. “For example, a developer could write a test that is to be executed with a real instance of Kafka, MySQL or any other technology. When the test is complete, it will tear down any dependencies. This allows developers to create self-contained, repeatable and idempotent tests that can be run either locally or in the continuous integration process (CI).”

In the background, Testcontainers utilizes its own containers to spin up the dependencies, Aleyner said. “So when a developer uses Testcontainers to say: ‘I want an instance of Kafka,’ before the test runs, the Testcontainers library will fetch the Kafka container, start it locally, handle all the port mapping and other details automatically.”

The larger impact of this approach is that it enables organizations to give developers more control and allow them to get more confidence in the software they write before checking in their code, Aleyner said.

“Previously, the only place developers used to discover integration issues was during the CI process. With Testcontainers, developers are able to shift this to the left, find issues faster and iterate quicker,” Aleyner said.

There is no substitute for speed in agile software development, and tools like this one help developers stomp down on the accelerator.

Started in Java

The Testcontainers project started in 2015 in Java and has grown to include hundreds of thousands of instances of Postgres, Elastic, MySQL, and other enterprise components, Aleyner said. Testcontainers has since evolved beyond the Java ecosystem libraries into .Net, Go, Node.js, Python, Rust and Haskell as those communities begin to realize the value of quicker iteration enabled through this library.

Since its inception, Testcontainers library has been implemented in seven languages, and it has also been embraced by the development community from large to small companies, Aleyner said. DoorDash, Uber, Spotify, Netflix, Capital One, and several others have talked publicly about using Testcontainers to simplify their Testing setup, he said.

“In aggregate, we are currently tracking around 6 million Docker image pulls for Testcontainers a month,” Aleyner said. “We have seen the Testcontainers library being downloaded 100 million times in January of this year; we crossed 50 million downloads in May of last year, so the technology is getting a lot of traction.”

Group Created with Sketch.
TNS owner Insight Partners is an investor in: The New Stack, AtomicJar, Docker.
THE NEW STACK UPDATE A newsletter digest of the week’s most important stories & analyses.