-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Allow JUnit Jupiter tests to be disabled when Docker is unavailable #1530
Allow JUnit Jupiter tests to be disabled when Docker is unavailable #1530
Conversation
Thanks - this seems like a sensible thing to come back into Testcontainers, so thanks for raising!
This was going to be my first question 😀 . Were there any strong reasons why you discounted this? Otherwise, I think it's the direction I'd lean towards... |
No strong reason. It just seemed less invasive as a separate annotation and I wasn't sure if you'd want it to be that prominent. If you're happy with an attribute ( |
Hi @wilkinsona! |
d6bc8fa
to
42036d7
Compare
This commit introduces a new attribute, disabledWithoutDocker, on @testcontainers that defaults to false. When set to true the class's tests are disabled when Docker in unavailable.
42036d7
to
0b18910
Compare
This should be ready for review now. I've switched to an attribute on |
Merged 🎉 Thank you @wilkinsona! 👍 |
We've been using Testcontainers in Spring Boot's test suite for some time now (thank you!) and are in the process of switching our tests to JUnit 5. As part of that, I wrote a customisation of
@Testcontainers
that uses JUnit 5's support conditional execution to disable the tests if Docker's unavailable. We find this really useful for people, particularly contributors, who want to build Boot and run its tests, but do not have Docker installed. The two files proposed here are what I've written for Boot.@DisabledWithoutDockerTestContainers
can be used as a replacement for@Testcontainers
, providing the above-described conditional execution.I've marked this PR as a draft as it's really just an initial proposal to see if there's interest from the Testcontainers community in having something like this be part of Testcontainers itself. I'm by no means wedded to the approach I've taken here and, if there is interest, I'm happy to modify things in whatever direction is desired. FWIW, rather than a new annotation, I also considered an attribute on
@Testcontainers
to opt in to the conditional execution with the existing extension then implementingExecutionCondition
.