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

Add JavaDoc to Spock's Testcontainers annotation #6802

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,47 @@ import java.lang.annotation.Retention
import java.lang.annotation.RetentionPolicy
import java.lang.annotation.Target

/**
* {@code @Testcontainers} is a Spock extension to activate automatic
* startup and stop of containers used in a test case.
*
* <p>The test containers extension finds all fields that extend
eddumelendez marked this conversation as resolved.
Show resolved Hide resolved
* {@link org.testcontainers.containers.GenericContainer} or
* {@link org.testcontainers.containers.DockerComposeContainer} and calls their
* container lifecycle methods. Containers annotated with {@link spock.lang.Shared}
* will be shared between test methods. They will be
* started only once before any test method is executed and stopped after the
* last test method has executed. Containers without {@link spock.lang.Shared}
* annotation will be started and stopped for every test method.</p>
*
* <p>The annotation {@code @Testcontainers} can be used on a superclass in
* the test hierarchy as well. All subclasses will automatically inherit
* support for the extension.</p>
*
* <p>Example:</p>
*
* <pre>
* &#64;Testcontainers
* class MyTestcontainersTests extends Specification {
*
* // will be started only once in setupSpec() and stopped after last test method
* &#64;Shared
* MySQLContainer MY_SQL_CONTAINER = new MySQLContainer()
*
* // will be started before and stopped after each test method
* PostgreSQLContainer postgresqlContainer = new PostgreSQLContainer()
* .withDatabaseName('foo')
* .withUsername('foo')
* .withPassword('secret')
*
* def 'test'() {
* expect:
* MY_SQL_CONTAINER.running
* postgresqlContainer.running
* }
* }
* </pre>
*/
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target([ElementType.TYPE, ElementType.METHOD])
Expand Down