javagradlemicronautmicronaut-test

Micronaut Test Resources: How to extend AbstractTestContainersProvider class


Micronaut documentation says:

For test resources which make use of Testcontainers, you may extend the base AbstractTestContainersProvider class.

My question is: how to add this class properly to the classpath of the test resources sourceset (I am using Gradle)


Solution

  • You will need to add the following dependencies to your build.gradle file:

    dependencies {
        testResourcesImplementation platform("io.micronaut:micronaut-bom:3.6.1")
        testResourcesImplementation "io.micronaut.testresources:micronaut-test-resources-testcontainers"
    }
    

    (note that I'm importing the Micronaut BOM so that you don't have to specify the test resources version, but you could use it directly)