Skip to content

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

Merged
bsideup merged 1 commit into
testcontainers:masterfrom
wilkinsona:disable-without-docker
Jul 21, 2019
Merged

bsideup merged 1 commit into
testcontainers:masterfrom
wilkinsona:disable-without-docker

Conversation

@wilkinsona

@wilkinsona wilkinsona commented Jun 4, 2019 •

Copy link
Copy Markdown
Contributor

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

rnorth commented Jun 6, 2019

Copy link
Copy Markdown
Member

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

wilkinsona commented Jun 6, 2019 •

Copy link
Copy Markdown
Contributor Author

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

bsideup commented Jul 16, 2019

Copy link
Copy Markdown
Member

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
wilkinsona force-pushed the disable-without-docker branch from 42036d7 to 0b18910 Compare July 17, 2019 10:44
@wilkinsona

Copy link
Copy Markdown
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

bsideup commented Jul 21, 2019

Copy link
Copy Markdown
Member

Merged 🎉 Thank you @wilkinsona! 👍

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.

3 participants