Skip to content

Best practices for tests that involve databases #5276

Answered by gruhn
ej-shafran asked this question in Q&A
Discussion options

You must be logged in to vote

#5022 is a similar question on how to randomize database relations. I think this also addresses this question if I understand you correctly:

Additionally - how would you create an arbitrary for values that depend on database returns (i.e. a user needs a department ID, which requires saving the department to the database...)?

Regarding this question:

What's the recommended way to write a property-based test that deals with a database? Is it to reset the database between each property run? That seems like it would consume a lot of time...

There is a strong assumption that every test run starts on a clean slate and that no relevant state is carried over. Otherwise shrinking can give bogu…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ej-shafran
Comment options

Answer selected by ej-shafran
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants