Testcontainers-java: @Testcontainers is not found in parentclass

Created on 9 Sep 2019  路  14Comments  路  Source: testcontainers/testcontainers-java

i am currently trying to upgrade from testcontainers version 1.11.4 to 1.12.1
it looks there might be an regression between that versions.

our current code (using v 1.11.4 looks like that). It uses an abstract base class that contains the @Testcontainers annotation.

@Testcontainers
abstract class MongoTests {
  ...
}

class MongoRepositoryIT(
...
) : MongoTests() {
  ...
}

this setup causes an runtime exception when upgrading to v 1.12.1:

Caused by: org.junit.platform.commons.PreconditionViolationException: Illegal state: required test class is not present in the current ExtensionContext
    at org.junit.platform.commons.util.Preconditions.condition(Preconditions.java:281)
    at org.junit.platform.commons.util.Preconditions.notNull(Preconditions.java:54)
    at org.junit.jupiter.api.extension.ExtensionContext.getRequiredTestClass(ExtensionContext.java:141)
    at org.testcontainers.junit.jupiter.TestcontainersExtension.findTestcontainers(TestcontainersExtension.java:62)
    at org.testcontainers.junit.jupiter.TestcontainersExtension.evaluateExecutionCondition(TestcontainersExtension.java:55)
    at org.junit.jupiter.engine.execution.ConditionEvaluator.evaluate(ConditionEvaluator.java:64)
    ... 41 more

i can work around that by putting the @Testcontainers annotation directly into the concrete test class:

@Testcontainers
class MongoRepositoryIT(...) 
good first issue help wanted modulejupiter resolutioacknowledged typbug

Most helpful comment

I'd be interested taking this on

All 14 comments

@abendt-mhp could you please try 1.12.0? I think it may be caused by https://github.com/testcontainers/testcontainers-java/pull/1530

sure. its the same exception with v 1.12.0. the workaround also works

@abendt-mhp thanks!

FYI this task is up for grabs if anyone wants to contribute it :) We will eventually take a look, but would also appreciate a fix contributed.

I confirm that org.testcontainers.junit.jupiter.inheritance.InheritedTests test fails if we remove @Testcontainers annotation from it.

I'd be interested taking this on

@bmuskalla thanks! It is yours 馃憤

I will soft timebox it to 7 days, just so that we can check in one week whether you are still working on it :)

@bsideup friendly ping :)

@bmuskalla thanks for the ping! 馃憤 there is one trivial thing (codestyle), happy to merge after 馃帀

Hello! Could you tell when this PR will be merged approximately?

am waiting for a new release that includes the fix as well :)

@Nipel-Crumple there is a PR (#1845) from @bmuskalla that waits a bit of polishing before we merge it

is it just because of the star import? i could fix that in case

Sorry, I totally missed the notification on this one. Pushed a new PR (#2001) for this with the imports fixed (and mssed up the old PR)

@bmuskalla thank you! 馃憤

Was this page helpful?
0 / 5 - 0 ratings