1

Some tests require running a database, for instance, using Test Containers Library. It obviously takes time to boot it up.

Is there a way to do this only once per entire Spek suite which spans across multiple files? The docs don't say anything about this.

Anyone knows why this has not been implemented?

kboom
  • 2,279
  • 3
  • 28
  • 43

1 Answers1

0

This answer is not Spek-specific, but Testcontainers objects expose a simple start() and stop() method, meaning that you don't have to rely on the test framework to control your container lifecycle if you don't want to. You can create a container in a static object that is separate from your test classes, and then access it across all tests if you like.

Please see an example here (Java example snippet below):

static {
    GenericContainer redis = new GenericContainer("redis:3-alpine")
            .withExposedPorts(6379);
    redis.start();
}

I would imagine an equivalent in Kotlin should be quite easy as an object (or similar).

Richard North
  • 432
  • 4
  • 6