ENG- Branchen
- Finanzen
Nearshore-Softwareentwicklung für den Finanzsektor – sicher, skalierbar und Compliance-gerechte Lösungen für Banking, Zahlungsverkehr und APIs.
- Einzelhandel
Softwareentwicklung für den Einzelhandel – E-Commerce, Kassensysteme, Logistik und KI-gestützte Personalisierung durch unsere Nearshore-Engineering-Teams.
- Verarbeitende Industrie
Nearshore-Softwareentwicklung für die Industrie – ERP-Systeme, IoT-Plattformen und Automatisierungstools zur Optimierung industrieller Abläufe.
- Finanzen
- Was wir tun
- Services
- Technologien
- Kooperationsmodelle
Kooperationsmodelle passend zu Ihren Bedürfnissen: Komplette Nearshoring Teams, deutschsprachige Experten vor Ort mit Nearshoring-Teams oder gemischte Teams mit unseren Partnern.
- Arbeitsweise
Durch enge Zusammenarbeit mit Ihrem Unternehmen schaffen wir maßgeschneiderte Lösungen, die auf Ihre Anforderungen abgestimmt sind und zu nachhaltigen Ergebnissen führen.
- Über uns
- Wer wir sind
Wir sind ein Full-Service Nearshoring-Anbieter für digitale Softwareprodukte, ein perfekter Partner mit deutschsprachigen Experten vor Ort, Ihre Business-Anforderungen stets im Blick
- Unser Team
Das ProductDock Team ist mit modernen Technologien und Tools vertraut und setzt seit 15 Jahren zusammen mit namhaften Firmen erfolgreiche Projekte um.
- Wozu Nearshoring
Wir kombinieren Nearshore- und Fachwissen vor Ort, um Sie während Ihrer gesamten digitalen Produktreise optimal zu unterstützen. Lassen Sie uns Ihr Business gemeinsam auf das nächste digitale Level anheben.
- Wer wir sind
- Unser Leistungen
- Karriere
- Arbeiten bei ProductDock
Unser Fokus liegt auf der Förderung von Teamarbeit, Kreativität und Empowerment innerhalb unseres Teams von über 120 talentierten Tech-Experten.
- Offene Stellen
Begeistert es dich, an spannenden Projekten mitzuwirken und zu sehen, wie dein Einsatz zu erfolgreichen Ergebnissen führt? Dann bist du bei uns richtig.
- Info Guide für Kandidaten
Wie suchen wir unsere Crew-Mitglieder aus? Wir sehen dich als Teil unserer Crew und erklären gerne unseren Auswahlprozess.
- Arbeiten bei ProductDock
- Newsroom
- News
Folgen Sie unseren neuesten Updates und Veröffentlichungen, damit Sie stets über die aktuellsten Entwicklungen von ProductDock informiert sind.
- Events
Vertiefen Sie Ihr Wissen, indem Sie sich mit Gleichgesinnten vernetzen und an unseren nächsten Veranstaltungen Erfahrungen mit Experten austauschen.
- News
- Blog
- Kontakt
19. Feb. 2026 •1 minute read
Spring Boot & Testcontainers
Bojan Ćorić
Sofware Engineer
Testcontainers is an open source library for providing throwaway, lightweight instances of anything that can run in a Docker container. Think of it as “Infrastructure-as-Code” specifically for your test suite. Instead of writing external scripts (like Bash or Docker Compose) to set up your environment before running tests, you define the environment inside your test code in your language of choice.
While it started in the Java world, Testcontainers is now a standardized protocol for testing across almost all major programming languages (Go, Python, C#, etc.).
The boilerplate era: Manual configuration
Before Spring Boot integrated tightly with Testcontainers, setting them up was cumbersome. Developers had to manually manage the container lifecycle and, more painfully, manually tell Spring Boot where to find these dynamically started containers.
// ❌ The verbose, manual way (avoid this now)<br>@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)<br>public class ManualConfigTest {<br><br> static PostgreSQLContainer<?> postgresContainer = new PostgreSQLContainer<>("postgres:18.1-alpine3.23");<br><br> @BeforeAll<br> static void startContainers() {<br> postgresContainer.start();<br> }<br><br> @DynamicPropertySource<br> static void redisProperties(DynamicPropertyRegistry registry) {<br> registry.add("spring.datasource.url", postgresContainer::getJdbcUrl);<br> registry.add("spring.datasource.username", postgresContainer::getUsername);<br> registry.add("spring.datasource.password", postgresContainer::getPassword);<br> }<br><br> @Autowired<br> private UserRepository userRepository;<br><br> @Test<br> void testDatabase() {<br> userRepository.save(new User(null, "John", "Doe", "john.doe@mail.com"));<br> List<User> users = userRepository.findAll();<br> assertThat(users).isNotEmpty();<br> }<br>}<br>
JUnit support: @Testcontainers
The first major quality-of-life improvement came from the Testcontainers JUnit 5 support. By using the @Testcontainers and @Container annotations, the library took over the lifecycle management (starting and stopping containers).
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)<br>@Testcontainers // Enable testcontainers support<br>public class ManualConfigTest {<br><br> @Container // JUnit manages lifecycle<br> static PostgreSQLContainer<?> postgresContainer = new PostgreSQLContainer<>("postgres:18.1-alpine3.23");<br><br> @DynamicPropertySource<br> static void redisProperties(DynamicPropertyRegistry registry) {<br> registry.add("spring.datasource.url", postgresContainer::getJdbcUrl);<br> registry.add("spring.datasource.username", postgresContainer::getUsername);<br> registry.add("spring.datasource.password", postgresContainer::getPassword);<br> }<br><br> @Autowired<br> private UserRepository userRepository;<br><br> @Test<br> void testDatabase() {<br> userRepository.save(new User(null, "John", "Doe", "john.doe@mail.com"));<br> List<User> users = userRepository.findAll();<br> assertThat(users).isNotEmpty();<br> }<br>}<br>
The modern way: @ServiceConnection
Spring Boot 3.1 introduced a game-changer: @ServiceConnection. Spring Boot now understands standard containers (Postgres, Mongo, Kafka, Redis, etc.). When you annotate a container with @ServiceConnection, Spring Boot automatically finds the connection details (URL, username, password, ports) and injects them into the application context.
No more property overrides. No more manual config.
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)<br>@Testcontainers<br>public class ManualConfigTest {<br><br> @Container<br> @ServiceConnection<br> static PostgreSQLContainer<?> postgresContainer = new PostgreSQLContainer<>("postgres:18.1-alpine3.23");<br><br> @Autowired<br> private UserRepository userRepository;<br><br> @Test<br> void testDatabase() {<br> userRepository.save(new User(null, "John", "Doe", "john.doe@mail.com"));<br> List<User> users = userRepository.findAll();<br> assertThat(users).isNotEmpty();<br> }<br>}<br>
Conclusion
Testcontainers has evolved from a niche library requiring lengthy setup to an absolute necessity for modern software development. It is no longer just a “nice-to-have”; it is the new standard for building reliable, production-grade applications. Testcontainers eliminates the “it works on my machine” and “it works with the mock” classes of bugs entirely.
Ready to implement this? You don’t have to start from scratch. I’ve created a GitHub repository featuring “real-world” setups for Postgres, Redis, and Kafka.
I also included a bonus section demonstrating how to manually configure containers when @ServiceConnection isn’t available, giving you full control over any service you need to containerize.
Clone the repo and start experimenting: https://github.com/Corke123/testcontainers-demo
Tags:Skip tags
Bojan Ćorić
Sofware EngineerBojan is a backend software developer at ProductDock, specializing in Java and Spring. He has been actively involved in developing robust and scalable backend systems for the past two years. His expertise in these technologies and his dedication to continuous learning make him a valuable asset in the field of software development.