Closed sascha-frinken closed 3 years ago
@sascha-frinken Why do you think so? What use case do you have for it to be on the compile classpath?
Because it doesn't work. Even the testcontainers documentation samples use testImplementation
.
If it helps I will create a sample app.
If one is using testcontainers with SQL-like databases, the testcontainers JDBC/R2DBC built-in support can be utilized; i.e. the testcontainer-modified URL scheme ( e.g. jdbc:tc:mysql:…
) along with the @MicronautTest
embedded server. In that case the testcontainer dependency should work with the testRuntimeOnly
scope. The micronaut-starter project has integration tests that do just that: create and test projects for the SQL-like databases, and they run fine.
However, if one wants to instantiate a testcontainer Container
object and wire it manually with the Micronaut embedded server, then the dependency needs to be testImplementation
. It's a bit more involved to do it that way, but that's necessary for the NoSQL database testcontainers. I am adding this for mongodb on Issue #614 where it's necessary, so I plan to also change the dependencies for the SQL-like database testcontainers to testImplementation
as well. As it is I'm also adding support for testcontainer junit/spock annotations and those dependencies expose the testcontainers core dependency as testImplementation
anyway.
When creating a project via micronaut starter with testcontainers and mariadb features it creates following gradle dependencies.
testRuntimeOnly("org.testcontainers:mariadb")
should betestImplementation("org.testcontainers:mariadb")