From e0ac6e1bbf83354c1de9e2c4a4c5e2050a7945a8 Mon Sep 17 00:00:00 2001 From: Simon Schneider <10846939+raynigon@users.noreply.github.com> Date: Tue, 23 Jun 2020 17:22:40 +0200 Subject: [PATCH] Convert Docs for the Spock Testframework Convert inline example code to use codeinclude macro for the Spock Testframework documentation. See #1158 for more details. --- docs/test_framework_integration/spock.md | 34 ++----------------- .../spock/PostgresContainerIT.groovy | 2 ++ 2 files changed, 5 insertions(+), 31 deletions(-) diff --git a/docs/test_framework_integration/spock.md b/docs/test_framework_integration/spock.md index bbe06a43e80..8528faf4490 100644 --- a/docs/test_framework_integration/spock.md +++ b/docs/test_framework_integration/spock.md @@ -9,37 +9,9 @@ Specifying the `@Testcontainers` annotation will instruct Spock to start and stop all testcontainers accordingly. This annotation can be mixed with Spock's `@Shared` annotation to indicate, that containers shouldn't be restarted between tests. -```groovy -@Testcontainers -class DatabaseTest extends Specification { - - @Shared - PostgreSQLContainer postgreSQLContainer = new PostgreSQLContainer() - .withDatabaseName("foo") - .withUsername("foo") - .withPassword("secret") - - def "database is accessible"() { - - given: "a jdbc connection" - HikariConfig hikariConfig = new HikariConfig() - hikariConfig.setJdbcUrl(postgreSQLContainer.jdbcUrl) - hikariConfig.setUsername("foo") - hikariConfig.setPassword("secret") - HikariDataSource ds = new HikariDataSource(hikariConfig) - - when: "querying the database" - Statement statement = ds.getConnection().createStatement() - statement.execute("SELECT 1") - ResultSet resultSet = statement.getResultSet() - resultSet.next() - - then: "result is returned" - int resultSetInt = resultSet.getInt(1) - resultSetInt == 1 - } -} -``` + +[PostgresContainerIT](../../modules/spock/src/test/groovy/org/testcontainers/spock/PostgresContainerIT.groovy) inside_block:PostgresContainerIT + ## Adding Testcontainers Spock support to your project dependencies diff --git a/modules/spock/src/test/groovy/org/testcontainers/spock/PostgresContainerIT.groovy b/modules/spock/src/test/groovy/org/testcontainers/spock/PostgresContainerIT.groovy index 6e090e77c33..4ac095bed6f 100644 --- a/modules/spock/src/test/groovy/org/testcontainers/spock/PostgresContainerIT.groovy +++ b/modules/spock/src/test/groovy/org/testcontainers/spock/PostgresContainerIT.groovy @@ -9,6 +9,7 @@ import spock.lang.Specification import java.sql.ResultSet import java.sql.Statement +// PostgresContainerIT { @Testcontainers class PostgresContainerIT extends Specification { @@ -42,3 +43,4 @@ class PostgresContainerIT extends Specification { } } +// }