Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Testcontainers is not found in parentclass #1843

Closed
ghost opened this issue Sep 9, 2019 · 14 comments
Closed

@Testcontainers is not found in parentclass #1843

ghost opened this issue Sep 9, 2019 · 14 comments

Comments

@ghost
Copy link

ghost commented Sep 9, 2019

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(...) 
@bsideup
Copy link
Member

bsideup commented Sep 9, 2019

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

@ghost
Copy link
Author

ghost commented Sep 9, 2019

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

@bsideup
Copy link
Member

bsideup commented Sep 9, 2019

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

@bmuskalla
Copy link
Contributor

I'd be interested taking this on

@bsideup
Copy link
Member

bsideup commented Sep 9, 2019

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

bmuskalla pushed a commit to bmuskalla/testcontainers-java that referenced this issue Sep 9, 2019
…#1843)

* Updated existing test with now expected behaviour
* @testcontainers is now @inherited
@bmuskalla
Copy link
Contributor

@bsideup friendly ping :)

@bsideup
Copy link
Member

bsideup commented Oct 1, 2019

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

@Nipel-Crumple
Copy link

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

@christian-draeger
Copy link

christian-draeger commented Oct 16, 2019

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

@bsideup
Copy link
Member

bsideup commented Oct 18, 2019

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

@christian-draeger
Copy link

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

bmuskalla pushed a commit to bmuskalla/testcontainers-java that referenced this issue Oct 24, 2019
…#1843)

* Updated existing test with now expected behaviour
* @testcontainers is now @inherited
@bmuskalla
Copy link
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)

@bsideup
Copy link
Member

bsideup commented Oct 24, 2019

@bmuskalla thank you! 👍

bsideup pushed a commit that referenced this issue Oct 26, 2019
* Updated existing test with now expected behaviour
* @testcontainers is now @inherited
@bsideup
Copy link
Member

bsideup commented Oct 26, 2019

Fixed by #2001

@bsideup bsideup closed this as completed Oct 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants