Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Testcontainers Desktop Provides Support for Investigations and Debugging

Testcontainers Desktop Provides Support for Investigations and Debugging

AtomicJar has introduced the freely available Testcontainers Desktop, a new application that supports Testcontainers, an open source framework which allows the use of real dependencies in unit tests. Testcontainers Desktop supports several features that aren't available in the Testcontainers framework and offers better support for investigations and debugging with fixed ports for containers and the option to freeze and reuse containers. Lastly, the application supports switching easily between container runtimes.

In November 2021, AtomicJar launched a new product, Testcontainers Cloud, in public beta which allows teams to run containers on a range of different environments and configurations. It required a desktop application, which resulted in Testcontainers Cloud Desktop. Now the TestContainers Cloud Desktop tool is donated to the community as the free Testcontainers Desktop application.

Testcontainers Desktop allows setting fixed ports instead of the default random ports used by Testcontainers. Containers with fixed ports are easier when debugging from, for example, IntelliJ. Freeze containers prevents the shutdown of a container and makes the test run forever. This makes it easier to investigate and debug. The freeze button may be unchecked after the analyses, to resume the test execution and default cleanup logic of Testcontainers. The application also allows switching the container runtime and supports solutions such as OrbStack, Colima, Rancher Desktop and Podman.

The Testcontainers framework makes it possible to write tests with JUnit that use databases, message brokers and any other service in a Docker container.

First the testcontainers BOM should be configured in the pom.xml:


After that, the dependencies may be used without specifying the version, for example for MySQL:


Alternatively, Gradle may be used to manage the dependencies:

implementation platform('org.testcontainers:testcontainers-bom:1.19.0') testImplementation('org.testcontainers:mysql')

Now the Docker container may be injected into JUnit tests. For example by injecting the MySQL container with the defaults value test for the database, username and password:

private static final MySQLContainer mySQLContainer = new MySQLContainer<>("mysql:8.1.0");

Alternatively, the default values may be overwritten with custom values:

private static final MySQLContainer mySQLContainer = new MySQLContainer<>("mysql:8.1.0")

Testcontainers provide various modules which facilitate the integration of those Docker containers. Alternatively, any Docker container may be used by using the GenericContainer class:

private static final GenericContainer myContainer = new GenericContainer("redis:7.2.1")	     

Finally, the container may be used inside the unit test to create a connection to the service and execute the unit test logic.

The documentation provides more information about Testcontainers for Java.

AtomicJar released a short demo video introducing Testcontainers Desktop. Testcontainers Desktop binaries are available for installation on Mac, Windows and Linux operating systems.

The Simple local development with Testcontainers Desktop guide provides more information. Next to that, Oleg Selajev, lead developer advocate at AtomicJar and Sergei Egorov, co-founder and CEO at AtomicJar, discussed and demonstrated Testcontainers Desktop on YouTube.

About the Author

Rate this Article