Skip to content

Instantly share code, notes, and snippets.

@stackunderflow111
Created November 19, 2021 03:25
Show Gist options
  • Select an option

  • Save stackunderflow111/a34e31b103135fde3955cad6a1330f88 to your computer and use it in GitHub Desktop.

Select an option

Save stackunderflow111/a34e31b103135fde3955cad6a1330f88 to your computer and use it in GitHub Desktop.
Testcontainers extension
public class PostgresContainerExtension implements BeforeAllCallback {
static private final PostgreSQLContainer<?> postgres = new PostgreSQLContainer<>("postgres:13-alpine");
@Override
public void beforeAll(ExtensionContext context) {
postgres.start();
System.setProperty("spring.datasource.url", postgres.getJdbcUrl());
System.setProperty("spring.datasource.username", postgres.getUsername());
System.setProperty("spring.datasource.password", postgres.getPassword());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment