SlideShare a Scribd company logo
Reality-Driven Testing
Using TestContainers
Oleksii Holub
- Working at Bitwarden 🧑💻
- Previously: Sentry
- Developer tooling & experience ⚙️
- Open-source maintainer 🐙
- CliWrap (~6M downloads, ~4K stars)
- YoutubeExplode (~2M downloads, ~3K stars)
- CliFx (~0.6M downloads, ~1.5k stars)
- …more
- Tech writer & speaker ✍️
- Unit Testing is Overrated (~400k reads)
- Prefer Fakes Over Mocks (~50k reads)
- Fluent Generics in C# (~15k reads)
- …more
- Microsoft MVP & GitHub Star ⭐
tyrrrz.me
Let’s take a step back
Why do we need testing?
Premises of (Automated) Testing
- Gain confidence that the software works correctly 😤
- Confidence is a product of authenticity 🪞
- Authentic test processes provide more confidence
- Contrived test processes provide less confidence
- Some components may be hard to test 🪞
- Because they are not easily accessible (e.g. cloud services)
- Because they are non-deterministic (e.g. dependent on outside effects)
- Because they are slow (e.g. relying on heavy I/O or computations)
- They can be replaced with test doubles
- Their behavior can be tested in isolation
- This reduces authenticity and thus confidence
tyrrrz.me
Prioritize this
Avoid this
tyrrrz.me
What the fuck?
Reasons to Use Real Dependencies
- Overuse of test doubles erodes confidence 🧑
- Less of the actual application surface is tested
- Potentially impossible states may be tested
- Especially when mucking with internal state
- Crucial infrastructural concerns are not tested
- Database interactions
- Request routing & handling
- Mocks make tests more complicated 🧑
- Tests should be trivial to understand
- Tests should not rely on implementation details
- Tests that contain logic need other tests to test themselves
- But we can’t just use real dependencies… 😔
- …or can we?
tyrrrz.me
🐋
✨ Containers! ✨
- Code-first container orchestrator (like Docker Compose)
- Single API, multiple platforms (.NET, Java, Go, NodeJS, Python, etc.)
- Works anywhere Docker is supported
- Open-source and community-maintained
- Built-in kits for popular services (e.g. Redis, MSSQL, Kafka)
- Single reusable infrastructure setup
tyrrrz.me
TestContainers
Reality-Driven Testing using TestContainers
tyrrrz.me
Configure the container
Wire the container to the
execution context
Use the container inside the
test
📺
Demo time
Performance Considerations
- Docker Pull is the slowest part 🐌
- Mostly just affects CI environments
- Many platforms pre-cache popular images
- Reducing image size is important
- Cold start overhead is constant ❄️
- Test suite becomes more efficient as it grows
- More tests means faster relative execution time
- Different isolation strategies can yield better results
tyrrrz.me
Test Isolation Strategies
- No isolation 🚫
- All tests share the same environment
- Environment gets reset after each test
- Tests cannot be parallelized
- Domain isolation 🛍🧑
- All tests share the same environment
- Operations are scoped within a logical scope (e.g. tenant)
- Each test gets its own scope
- Storage isolation 📝
- All tests share the same environment
- Each test gets its own database instance
- Environment isolation 📦
- Each test gets its own environment
tyrrrz.me
Summary
- Testing against real dependencies…
- Is easy (as long as there’s a Docker image) ✅
- Is quite fast ✅
- Simplifies testing code ✅
- Provides more confidence ✅
- TestContainers…
- Supports many different development platforms ✅
- Lets you easily share test infra between projects ✅
- Testable software…
- Is not just about dependency inversion and interfaces ❌
- Is sometimes just about using the right technologies ✅
tyrrrz.me
Thank you!
tyrrrz.me

More Related Content

PPTX
Simplifying Integration Testing in a Containerized World
PDF
Prod-Like Integration Testing for Distributed Containerized Applications
PPTX
Testcontainers: Reliable, Isolated, and Reproducible Testing for External Dep...
PDF
Testcontainers - Geekout EE 2017 presentation
PDF
Testing for fun in production Into The Box 2018
PPTX
Introduction to TestContainers for Integration Testing
PDF
Continuous Delivery at Snyk
PPTX
DockerCon EU 2015: Stop Being Lazy and Test Your Software!
Simplifying Integration Testing in a Containerized World
Prod-Like Integration Testing for Distributed Containerized Applications
Testcontainers: Reliable, Isolated, and Reproducible Testing for External Dep...
Testcontainers - Geekout EE 2017 presentation
Testing for fun in production Into The Box 2018
Introduction to TestContainers for Integration Testing
Continuous Delivery at Snyk
DockerCon EU 2015: Stop Being Lazy and Test Your Software!

Similar to Reality-Driven Testing using TestContainers (20)

PDF
Level Up Your Integration Testing With Testcontainers
PDF
Stop Being Lazy and Test Your Software
PDF
Technical Report: My Container
PDF
"To cover uncoverable", Andrii Shumada
PPTX
DevSecCon Tel Aviv 2018 - Security Testing for Containerised Apps by Omer Levi
PDF
Reaching Production Faster with Containers in Testing
PPTX
Security Testing for Containerized Applications
PDF
Test Driven Design & Deployment
PDF
UPC Plone Testing Talk
PPTX
Test automation expert days
PDF
Accelerate Your Automation Testing Effort using TestProject & Docker | Docker...
PDF
Scaling Your Tests: Continued Change Without Fear
PPTX
Test Strategies in Microservices
PPTX
JLove - Replicating production on your laptop using the magic of containers
PPTX
JBCN_Testing_With_Containers
PPTX
Test Automation Architecture in Microservices
PDF
Testing in FrontEnd World by Nikita Galkin
PPTX
АНДРІЙ ШУМАДА «To Cover Uncoverable» Online WDDay 2022 js
PDF
Building Efficient Parallel Testing Platforms with Docker
PDF
BDD Testing and Automating from the trenches - Presented at Into The Box June...
Level Up Your Integration Testing With Testcontainers
Stop Being Lazy and Test Your Software
Technical Report: My Container
"To cover uncoverable", Andrii Shumada
DevSecCon Tel Aviv 2018 - Security Testing for Containerised Apps by Omer Levi
Reaching Production Faster with Containers in Testing
Security Testing for Containerized Applications
Test Driven Design & Deployment
UPC Plone Testing Talk
Test automation expert days
Accelerate Your Automation Testing Effort using TestProject & Docker | Docker...
Scaling Your Tests: Continued Change Without Fear
Test Strategies in Microservices
JLove - Replicating production on your laptop using the magic of containers
JBCN_Testing_With_Containers
Test Automation Architecture in Microservices
Testing in FrontEnd World by Nikita Galkin
АНДРІЙ ШУМАДА «To Cover Uncoverable» Online WDDay 2022 js
Building Efficient Parallel Testing Platforms with Docker
BDD Testing and Automating from the trenches - Presented at Into The Box June...
Ad

More from Oleksii Holub (8)

PDF
Intro to CliWrap
PDF
Intro to CliWrap
PDF
Expression trees in C#
PDF
Fallacies of unit testing
PDF
Expression trees in c#
PDF
GitHub Actions in action
PDF
Alexey Golub - Writing parsers in c# | 3Shape Meetup
PDF
Alexey Golub - Dependency absolution (application as a pipeline) | Svitla Sma...
Intro to CliWrap
Intro to CliWrap
Expression trees in C#
Fallacies of unit testing
Expression trees in c#
GitHub Actions in action
Alexey Golub - Writing parsers in c# | 3Shape Meetup
Alexey Golub - Dependency absolution (application as a pipeline) | Svitla Sma...
Ad

Recently uploaded (20)

PPTX
Transform Your Business with a Software ERP System
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
PDF
Nekopoi APK 2025 free lastest update
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
PDF
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
PPTX
ai tools demonstartion for schools and inter college
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Digital Strategies for Manufacturing Companies
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PDF
System and Network Administraation Chapter 3
Transform Your Business with a Software ERP System
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
VVF-Customer-Presentation2025-Ver1.9.pptx
Nekopoi APK 2025 free lastest update
Operating system designcfffgfgggggggvggggggggg
How to Choose the Right IT Partner for Your Business in Malaysia
wealthsignaloriginal-com-DS-text-... (1).pdf
Why TechBuilder is the Future of Pickup and Delivery App Development (1).pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Claude Code: Everyone is a 10x Developer - A Comprehensive AI-Powered CLI Tool
Flood Susceptibility Mapping Using Image-Based 2D-CNN Deep Learnin. Overview ...
ai tools demonstartion for schools and inter college
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Odoo POS Development Services by CandidRoot Solutions
Digital Strategies for Manufacturing Companies
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Odoo Companies in India – Driving Business Transformation.pdf
Which alternative to Crystal Reports is best for small or large businesses.pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
System and Network Administraation Chapter 3

Reality-Driven Testing using TestContainers

  • 2. Oleksii Holub - Working at Bitwarden 🧑💻 - Previously: Sentry - Developer tooling & experience ⚙️ - Open-source maintainer 🐙 - CliWrap (~6M downloads, ~4K stars) - YoutubeExplode (~2M downloads, ~3K stars) - CliFx (~0.6M downloads, ~1.5k stars) - …more - Tech writer & speaker ✍️ - Unit Testing is Overrated (~400k reads) - Prefer Fakes Over Mocks (~50k reads) - Fluent Generics in C# (~15k reads) - …more - Microsoft MVP & GitHub Star ⭐ tyrrrz.me
  • 3. Let’s take a step back Why do we need testing?
  • 4. Premises of (Automated) Testing - Gain confidence that the software works correctly 😤 - Confidence is a product of authenticity 🪞 - Authentic test processes provide more confidence - Contrived test processes provide less confidence - Some components may be hard to test 🪞 - Because they are not easily accessible (e.g. cloud services) - Because they are non-deterministic (e.g. dependent on outside effects) - Because they are slow (e.g. relying on heavy I/O or computations) - They can be replaced with test doubles - Their behavior can be tested in isolation - This reduces authenticity and thus confidence tyrrrz.me Prioritize this Avoid this
  • 6. Reasons to Use Real Dependencies - Overuse of test doubles erodes confidence 🧑 - Less of the actual application surface is tested - Potentially impossible states may be tested - Especially when mucking with internal state - Crucial infrastructural concerns are not tested - Database interactions - Request routing & handling - Mocks make tests more complicated 🧑 - Tests should be trivial to understand - Tests should not rely on implementation details - Tests that contain logic need other tests to test themselves - But we can’t just use real dependencies… 😔 - …or can we? tyrrrz.me
  • 8. - Code-first container orchestrator (like Docker Compose) - Single API, multiple platforms (.NET, Java, Go, NodeJS, Python, etc.) - Works anywhere Docker is supported - Open-source and community-maintained - Built-in kits for popular services (e.g. Redis, MSSQL, Kafka) - Single reusable infrastructure setup tyrrrz.me TestContainers
  • 10. tyrrrz.me Configure the container Wire the container to the execution context Use the container inside the test
  • 12. Performance Considerations - Docker Pull is the slowest part 🐌 - Mostly just affects CI environments - Many platforms pre-cache popular images - Reducing image size is important - Cold start overhead is constant ❄️ - Test suite becomes more efficient as it grows - More tests means faster relative execution time - Different isolation strategies can yield better results tyrrrz.me
  • 13. Test Isolation Strategies - No isolation 🚫 - All tests share the same environment - Environment gets reset after each test - Tests cannot be parallelized - Domain isolation 🛍🧑 - All tests share the same environment - Operations are scoped within a logical scope (e.g. tenant) - Each test gets its own scope - Storage isolation 📝 - All tests share the same environment - Each test gets its own database instance - Environment isolation 📦 - Each test gets its own environment tyrrrz.me
  • 14. Summary - Testing against real dependencies… - Is easy (as long as there’s a Docker image) ✅ - Is quite fast ✅ - Simplifies testing code ✅ - Provides more confidence ✅ - TestContainers… - Supports many different development platforms ✅ - Lets you easily share test infra between projects ✅ - Testable software… - Is not just about dependency inversion and interfaces ❌ - Is sometimes just about using the right technologies ✅ tyrrrz.me