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

Allow JUnit Jupiter tests to be disabled when Docker is unavailable #1530

Merged
merged 1 commit into from
Jul 21, 2019

Conversation

wilkinsona
Copy link
Contributor

@wilkinsona wilkinsona commented Jun 4, 2019

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 implementing ExecutionCondition.

@rnorth
Copy link
Member

rnorth commented Jun 6, 2019

Thanks - this seems like a sensible thing to come back into Testcontainers, so thanks for raising!

rather than a new annotation, I also considered an attribute on @testcontainers to opt in to the condition execution with the existing extension then implementing ExecutionCondition.

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

@wilkinsona
Copy link
Contributor Author

wilkinsona commented Jun 6, 2019

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 (disableWithoutDocker, defaulting to false?) then let me know and I'll update this draft accordingly.

@bsideup bsideup added this to the next milestone Jul 16, 2019
@bsideup
Copy link
Member

bsideup commented Jul 16, 2019

Hi @wilkinsona!
It seems that making it an attribute would be a better choice 👍
I hope that's okay to ask you to adjust the PR :) Would be a great addition to the next release!

@wilkinsona wilkinsona force-pushed the disable-without-docker branch 2 times, most recently from d6bc8fa to 42036d7 Compare July 17, 2019 10:37
@wilkinsona wilkinsona marked this pull request as ready for review July 17, 2019 10:37
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.
@wilkinsona
Copy link
Contributor Author

This should be ready for review now. I've switched to an attribute on @Testcontainers and added some tests too.

@bsideup bsideup merged commit 151b93a into testcontainers:master Jul 21, 2019
@bsideup
Copy link
Member

bsideup commented Jul 21, 2019

Merged 🎉 Thank you @wilkinsona! 👍

@bsideup bsideup changed the title Allow tests to be disabled when Docker is unavailable Allow JUnit Jupiter tests to be disabled when Docker is unavailable Jul 21, 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 this pull request may close these issues.

None yet

3 participants