Skip to content

@Testcontainers is not found in parentclass #1843

Closed

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

  1. bsideup commented on Sep 9, 2019

    @bsideup
    Member

    @abendt-mhp could you please try 1.12.0? I think it may be caused by #1530

  2. bsideup commented on Sep 9, 2019

    @bsideup
    Member

    @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.

  3. bmuskalla commented on Sep 9, 2019

    @bmuskalla
    Contributor

    I'd be interested taking this on

  4. bsideup commented on Sep 9, 2019

    @bsideup
    Member

    @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 :)

  5. added a commit that references this issue on Sep 9, 2019
  6. bmuskalla commented on Sep 30, 2019

    @bmuskalla
    Contributor

    @bsideup friendly ping :)

  7. bsideup commented on Oct 1, 2019

    @bsideup
    Member

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

  8. Nipel-Crumple commented on Oct 16, 2019

    @Nipel-Crumple

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

  9. christian-draeger commented on Oct 16, 2019

    @christian-draeger

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

  10. bsideup commented on Oct 18, 2019

    @bsideup
    Member

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

  11. christian-draeger commented on Oct 22, 2019

    @christian-draeger

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

  12. added a commit that references this issue on Oct 24, 2019
  13. bmuskalla commented on Oct 24, 2019

    @bmuskalla
    Contributor

    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)

  14. bsideup commented on Oct 24, 2019

    @bsideup
    Member

    @bmuskalla thank you! 👍

  15. added a commit that references this issue on Oct 26, 2019
  16. bsideup commented on Oct 26, 2019

    @bsideup
    Member

    Fixed by #2001

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