Examples of a collection fixture? #412
-
Hi, I'm attempting to write xunit integration tests for repositories that store data in postgresql. I'm using a collection fixture to create my postgresql container so it can be shared among all my repo test classes. The tests all work perfectly when I step through them in debug, but every one of them fails if I just run them. Each time, I get the same error for every test method:
My first thought was that I was inadvertently re-using a DBconnection, but I create a new one for each test method. Since the tests all work if I create the container manually (without using testcontainers), I figure I have to be doing something wrong in the testcontainer fixture setup. Does anybody have an example of a collection fixture they use for multiple test classes that they could share? Super-extra bonus gratitude points if it's for a database... |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Can you share some of your code (especially the
Sounds like a race condition. Did you check the wait strategy? Is the container ready to accept connections, etc.? Edit: I attached a small example. Maybe that helps: PostgreSqlSample.zip |
Beta Was this translation helpful? Give feedback.
Can you share some of your code (especially the
CollectionDefinition
)? I use collection fixtures without any issues for databases too. It looks like your connection is broken somehow.Sounds like a race condition. Did you check the wait strategy? Is the container ready to accept connections, etc.?
Edit: I attached a small example. Maybe that helps: PostgreSqlSample.zip