Testcontainers-java: More examples needed

Created on 12 Jan 2019  路  7Comments  路  Source: testcontainers/testcontainers-java

We already have some examples in examples/ folder:
https://github.com/testcontainers/testcontainers-java/tree/master/examples

But some are outdated, and some examples are missing. This is a meta-issue to aggregate all example requests.

Current list:

We marked them as good first issue because we think that contributing examples is a good way to learn Testcontainers and do OSS contributions :)

Comment on the issue you want to work on and it is yours!

good first issue help wanted stale typdocs typhousekeeping

All 7 comments

If I can feature creep a bit, I'd love to see an example of "I used to use h2, but really would rather test everything with mysql." What I mean is, a way to use mysql everywhere without having to change all my test classes to inherit from AbstractIntegrationTest.

Pretty sure https://www.testcontainers.org/usage/database_containers.html#jdbc-url gets me part of the way. The part I'm missing is getting a fresh schema with each test. At the moment, I only see how to do this with a doesn't-yet-exist gradle plugin and some

test {
    beforeTest {
        // reset the schema here
    }
}

Has someone found a better way?

@dbyron0 @DirtiesContext from Spring? It will re-instantiate a JDBC driver, and Testcontainers will re-create a container.
Although this is not really related to Testcontainers and probably should be done on the test level itself

Hmmm...hadn't thought of that. I'm torn about having to edit all my test classes, but maybe it really is the better way, because you're right, it's not actually every single test class, only a large subset.

Thank you.

I have a nice example how to create a cluster of containers with a shared network, based on the work here (https://github.com/testcontainers/testcontainers-java/pull/1246). I can contribute that as well.

@michael-simons Would be great if you add it to the new Gradle examples project :slightly_smiling_face:

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this is a mistake, please reply to this comment to keep it open. If there isn't one already, a PR to fix or at least reproduce the problem in a test case will always help us get back on track to tackle this.

This issue has been automatically closed due to inactivity. We apologise if this is still an active problem for you, and would ask you to re-open the issue if this is the case.

Was this page helpful?
0 / 5 - 0 ratings