mardi 2 juillet 2019

How can i run a method, before all test classes to start a docker-compose once

We have a homepage and a postgres db, which i want to start via docker-compose before i run my test classes. Actually i have an extension with BeforeAllCallback, but i don't want to run the docker-compose before each test class. I want to run it once before all test classes. Did someone know a way to do that?

So this is what i have now:

public class DockerExtension implements BeforeAllCallback
    @Override
    public void beforeAll(ExtensionContext context) {

        new DockerComposeContainer<>(
                new File("docker-compose.yml"))
                .withExposedService("bpgres_1", 5432, Wait.forListeningPort().withStartupTimeout(Duration.ofSeconds(15)))
                .withExposedService("bp_1", 8090, Wait.forListeningPort().withStartupTimeout(Duration.ofSeconds(15)))
                .withLocalCompose(true)
                .start();

    }

Aucun commentaire:

Enregistrer un commentaire