Actually problem i am facing is no test state isoloation, my pg instance contains the data inserted by some other test and when new test tries to insert that same data it is throwing exception, what to do? how to spin-up a new container start of each test and tear ti down after it OR how to restore pg state when all of it's tables/seqeuences just populated? OR how to sort of rollback things after test so that nothing commits to the db in the end? Appreciate the help in advance
You can use the beforeAll / beforeEach hooks of your test runner to make this happen. I understand that marking the test container as static, in a test class (in Java) is equivalent to beforeAll
The end is kind of misleading. You briefly mentioned testing vs. development environment, but through the code it leaves the impression that testcontainers and docker-compose work together, which is not really the case. I think you should have wiped all testcontainers code to make it clear. Great talk nonetheless, this is very good stuff and insanely speeds up development testing.
The only thing missing here is to run the docker containers once for all the test cases because starting/stoping the containers for all test classes is time consuming
Right. If you make them beans and let Spring mange its lifecycle, then you only start them once. You need to make sure you cleanup everything between tests to avoid test-pollution. I didn't have enough time to show that but I'll keep in mind for the future. Thanks for your feedback.
Great talk. Just started using testcontainers. Gr8 technology
Great presentation
Thank you!
Actually problem i am facing is no test state isoloation, my pg instance contains the data inserted by some other test and when new test tries to insert that same data it is throwing exception, what to do?
how to spin-up a new container start of each test and tear ti down after it
OR
how to restore pg state when all of it's tables/seqeuences just populated?
OR
how to sort of rollback things after test so that nothing commits to the db in the end?
Appreciate the help in advance
You can use the beforeAll / beforeEach hooks of your test runner to make this happen. I understand that marking the test container as static, in a test class (in Java) is equivalent to beforeAll
Good talk, I like it. What is the theme of intellij you use?
Thanks! I use one built-in "Light with Light Header"
Awesome
Thank you so much 🤩! I'm glad you liked it
Why use RestAssured instead of WebTestClient?
The end is kind of misleading. You briefly mentioned testing vs. development environment, but through the code it leaves the impression that testcontainers and docker-compose work together, which is not really the case. I think you should have wiped all testcontainers code to make it clear.
Great talk nonetheless, this is very good stuff and insanely speeds up development testing.
The only thing missing here is to run the docker containers once for all the test cases because starting/stoping the containers for all test classes is time consuming
Right. If you make them beans and let Spring mange its lifecycle, then you only start them once. You need to make sure you cleanup everything between tests to avoid test-pollution. I didn't have enough time to show that but I'll keep in mind for the future.
Thanks for your feedback.
just do a container reuse if you dont want to raise container per test