Running Testcontainers Tests Using Azure Pipelines

December 8, 2025 · 721 words · 4 min

Testcontainers is a testing library that enables you to run your tests with dependencies like databa

Testcontainers is a testing library that enables you to run your tests with dependencies like databases, message queues, search engines etc., using ephemeral Docker containers. manage the lifecycle of these Docker containers using a programmable API, which gives finer control over the required application dependencies setup. is a cloud-based continuous integration and continuous delivery (CI/CD) service provided by Microsoft as part of the Azure DevOps suite of tools. Azure Pipelines is widely used by developers and DevOps teams to streamline the software development and delivery process. This article will explore how to run Testcontainers-based tests using Azure Pipelines on the Azure DevOps platform. We will use an , which you can find on GitHub. In this article, we are going to create a project on GitHub and configure it to use Azure Pipelines as our CI platform. If you already have an application, you can use it or create a new project. We are going to use the repository, which is a Spring Boot application using Testcontainers for testing. To start, create the file with the following content in the root directory of the project, then commit and push the changes. We are using to configure the desired JDK version to use; in our case, we are using Java 17. Then, we configured a step to run the command to run the tests using the Maven build tool. Now, go to the and log in using your credentials. Click the button and then enter the Project name, select the and choose . Once the project is created, go into and choose . You can configure the pipelines for your project by following the steps below: Because Azure Pipelines runners already have Docker installed and configured, the tests should run successfully (Figure 1). As shown in this image, the tests ran successfully using the default Docker support on Azure Pipeline runners. As your project grows bigger and bigger, you may use more containers for your tests, and the test execution may become resource-intensive. Instead of running the test dependency containers on Azure pipeline runner itself, you can use , where the containers will be running on a cloud environment. By using Testcontainers Cloud, you don’t even need to have Docker daemon running on the runner. Containers will be running in the on-demand cloud environments, so you don’t need to use powerful CI workers with high CPU/memory for your builds. Let’s see how to use Testcontainers Cloud with minimal setup and run Testcontainers-based tests. If you don’t have a Testcontainers Cloud account already, create an account as follows and get a Service Account Token (Figure 2): Next, we need to set the as an environment variable: Next, update the file as follows: We have included a step before executing our tests to start the Testcontainers Cloud agent by passing the as an environment variable, looking up the value from the variable we defined earlier in Pipeline. Now if you commit the updated file, then the pipeline will run the tests using Testcontainers Cloud. You should see the following logs statements, indicating that the Testcontainers-based tests are using Testcontainers Cloud instead of the default Docker daemon. We can also leverage Testcontainers Cloud’s TurboMode in conjunction with build tools that feature parallel run capabilities to run our tests in parallel. In the case of Maven, we can use the system property to specify the degree of parallelization. For Gradle, we can specify the degree of parallelization using the maxParallelForks property. We can enable parallel execution of our tests using four forks in as follows: For more information on using TurboMode, please .  In this article, we have explored how to run Testcontainers-based tests on Azure Pipelines using the default Docker daemon. Then we learned how to create a Testcontainers Cloud account and configure the pipeline to run tests using Testcontainers Cloud. We also explored leveraging Testcontainers Cloud TurboMode combined with your build tool’s parallel execution capabilities. Although we have demonstrated this setup using a Java project as an example, Testcontainers libraries exist for other popular languages too, and you can follow the same pattern of configuration to run your Testcontainers-based tests on Azure Pipelines in Golang, .NET, Python, Node.js, etc. You can get started with Testcontainers Cloud by .