Ease Keycloak extension development with test-containers

Hello Keycloak developers,

I think I found a neat way to develop and test custom Keycloak extensions
with a running Keycloak Docker container by using test-containers.

The trick is to dynamically map the target/classes folder into the
started container as an exploded deployment which can then be redeployed on demand
on class-file contents change during IDE build.

This allows speedy development cycles by skipping intermediate packaging steps and
eases testing. You can use the same approach in your integration tests. Since we expose our target/classes to the stock Keycloak container started by test-containers
during integration tests we can directly test our extensions without any packaging.

A demo for this approach (for development and testing) can be found here:

As always, I’m looking forward to hear your feedback :slight_smile:


1 Like

I also used testcontainers inside my project (https://github.com/adorsys/keycloak-config-cli) to run test agist a real Keycloak instance. It worked like a charm and the containers are also started if I run the tests without maven, e.g. directly via IDE.

1 Like

Using test-containers for testing Keycloak is quite common, but what’s new is to use it for (extension / theme) development too :slight_smile:

Btw. I really like the keycloak-config-cli tool, it’s a good alternative to provisioning Keycloak with keycloak-terraform.

1 Like