Skip to content

@Testcontainers is not found in parentclass #1843

Description

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(...) 

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions