Skip to content

Postgres container that will be run only once per test suite #5601

Discussion options

You must be logged in to vote

You can opt-in for container reuse feature.

  1. Define container with withReuse(true)
@Shared
public GenericContainer container = new GenericContainer(SpockTestImages.HTTPD_IMAGE)
        .withExposedPorts(80)
        .withReuse(true)
  1. opt-in to reuse in ~/.testcontainers.properties
testcontainers.reuse.enable=true
  1. containers should be started manually using container.start(). See docs

Note
This is an experimental feature. Containers using withReuse(true) won't stop after all tests are finished.

You can create a BaseITSpecification which declares the container to be reused across your tests. Take into account that the container definition should be the same to be reused.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@kiview
Comment options

Answer selected by Krzysztof-Lempicki
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants