testcontainers / testcontainers/testcontainers-java
Restart the tc_initscript before each test
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 8.7k
- Forks
- 1.9k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 9
Description
Hi,
I successfully set up TestContainers in a quarkus application with this kind of configuration:
%test.quarkus.datasource.url=jdbc:tc:postgresql:11:///dbname?TC_INITSCRIPT=file:src/test/resources/init.sql
However in some tests I delete rows; and I'd like that each test start with the same database state.
Is there any way to force TestContainers to re-run the initscript before each test, or even each test class?
PS: I could probably init the containers myself from test classes to achieve it; however I set up 3 different databases and it would need lot of boilerplate code.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reading the Testcontainers handling of the TC_INITSCRIPT option and its container lifecycle during JUnit tests. Define whether rerunning the script per test or test class is supported, and consider how the behavior would work for multiple configured databases without requiring setup boilerplate.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, java, postgresql
- Domain
- databases, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100