Open jyaquinas opened 2 years ago
Ref: https://www.testcontainers.org/test_framework_integration/manual_lifecycle_control/#singleton-containers https://rieckpil.de/reuse-containers-with-testcontainers-for-fast-integration-tests/
@SpringBootTest public abstract class CassandraBaseContainer { static final CassandraContainer cassandraContainer; static { cassandraContainer = (CassandraContainer) new CassandraContainer("cassandra:4.0.3") .withExposedPorts(9042) .withReuse(true); cassandraContainer.start(); setupCassandra(); } private static final String KEYSPACE_NAME = "TestKeyspace"; static void setupCassandra() { System.setProperty("spring.data.cassandra.keyspace-name", KEYSPACE_NAME); System.setProperty("spring.data.cassandra.contact-points", cassandraContainer.getHost()); System.setProperty("spring.data.cassandra.port", String.valueOf(cassandraContainer.getMappedPort(9042))); try (Session session = cassandraContainer.getCluster().connect()) { session.execute("CREATE KEYSPACE IF NOT EXISTS " + KEYSPACE_NAME + " WITH replication = \n" + "{'class':'SimpleStrategy','replication_factor':'1'};"); } } }
아직 디버깅중..
와 이거 그때말한 도커 문제가 아니고 다른 문제이면 어떡하지..?
Test passes when executed within the class ('Run PostsRepositoryTest'), but fails when executed from the package ('Run tests in com.example...')
Ref: https://www.testcontainers.org/test_framework_integration/manual_lifecycle_control/#singleton-containers https://rieckpil.de/reuse-containers-with-testcontainers-for-fast-integration-tests/
아직 디버깅중..