Listen to this Post
System integration testing is the perfect testing approach for modular monoliths. It’s an approach to testing the interactions between various modules within a single system. This method ensures that all components work together as expected, providing maximum confidence in your code.
You Should Know:
To implement system integration testing in your CI/CD pipeline, you can use tools like Testcontainers and Docker. These tools allow you to spin up external services as containers and access them in your tests. Here’s how you can set up and run integration tests with these services:
1. PostgreSQL:
- Use the following command to spin up a PostgreSQL container:
docker run --name test-postgres -e POSTGRES_PASSWORD=mysecretpassword -d -p 5432:5432 postgres
- Connect to the PostgreSQL container from your application code using the connection string:
Host=localhost;Port=5432;Database=testdb;Username=postgres;Password=mysecretpassword
2. Keycloak:
- Start a Keycloak container with:
docker run --name test-keycloak -e KEYCLOAK_USER=admin -e KEYCLOAK_PASSWORD=admin -d -p 8080:8080 jboss/keycloak
- Access Keycloak from your tests by configuring the URL:
http://localhost:8080/auth
3. Redis:
- Launch a Redis container using:
docker run --name test-redis -d -p 6379:6379 redis
- Connect to Redis from your application with:
localhost:6379
Example Test Setup with Testcontainers in .NET:
using Xunit;
using Testcontainers.PostgreSql;
using Testcontainers.Redis;
using Testcontainers.Keycloak;
public class IntegrationTests : IAsyncLifetime
{
private readonly PostgreSqlContainer _postgresContainer = new PostgreSqlBuilder().Build();
private readonly RedisContainer _redisContainer = new RedisBuilder().Build();
private readonly KeycloakContainer _keycloakContainer = new KeycloakBuilder().Build();
public async Task InitializeAsync()
{
await _postgresContainer.StartAsync();
await _redisContainer.StartAsync();
await _keycloakContainer.StartAsync();
}
public async Task DisposeAsync()
{
await _postgresContainer.DisposeAsync();
await _redisContainer.DisposeAsync();
await _keycloakContainer.DisposeAsync();
}
[Fact]
public void TestDatabaseConnection()
{
var connectionString = _postgresContainer.GetConnectionString();
// Your test logic here
}
}
What Undercode Say:
System integration testing is a crucial step in ensuring that your modular monoliths function as expected. By leveraging tools like Testcontainers and Docker, you can simulate real-world environments and test interactions between different modules seamlessly. This approach not only enhances the reliability of your code but also streamlines your CI/CD pipeline.
For more advanced testing techniques, check out Milan Jovanović’s article on System Integration Testing.
Additional Commands for Linux/Windows:
- Linux:
- To check running Docker containers:
docker ps
- To stop all running containers:
docker stop $(docker ps -q)
-
Windows:
- To list all Docker containers:
docker ps -a
- To remove all stopped containers:
docker container prune
By integrating these practices into your workflow, you can ensure a robust and efficient testing environment for your applications.
References:
Reported By: Milan Jovanovic – Hackers Feeds
Extra Hub: Undercode MoN
Basic Verification: Pass ✅



