Code Monkey home page Code Monkey logo

testcontainers-extensions's Introduction

Testcontainers Extensions

Minimum required Java version Maven Central GitHub Action Coverage Maintainability Rating Lines of Code

Testcontainers Extensions with advanced testing capabilities.

Makes testing & asserts with Testcontainers even easier.

Featured extensions

Usage

Here is an example of Kafka Extension where KafkaContainer is started in PER_RUN mode with topic reset per method:

@TestcontainersKafka(mode = ContainerMode.PER_RUN,
        topics = @Topics(value = "my-topic-name", reset = Topics.Mode.PER_METHOD))
class ExampleTests {

    @ConnectionKafka
    private KafkaConnection kafkaConnection;

    @Test
    void test() {
        var consumer = kafkaConnection.subscribe("my-topic-name");
        kafkaConnection.send("my-topic-name", Event.ofValue("event1"), Event.ofValue("event2"));
        consumer.assertReceivedAtLeast(2, Duration.ofSeconds(5));
    }
}

Here is an example of Postgres Extension where PostgresContainer is started PER_RUN mode and migrations are applied per method:

@TestcontainersPostgreSQL(mode = ContainerMode.PER_RUN,
        migration = @Migration(
                engine = Migration.Engines.FLYWAY,
                apply = Migration.Mode.PER_METHOD,
                drop = Migration.Mode.PER_METHOD))
class ExampleTests {

    @ConnectionPostgreSQL
    private JdbcConnection postgresConnection;

    @Test
    void test() {
        postgresConnection.execute("INSERT INTO users VALUES(1);");
        var usersFound = postgresConnection.queryMany("SELECT * FROM users;", r -> r.getInt(1));
        assertEquals(1, usersFound.size());
    }
}

testcontainers-extensions's People

Contributors

goodforgod avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.