0

This question came about because I had a set of unit tests fail and I looked up this question. Another stack overflow user was asking about creating sequential unit tests in a certain order, but users were responding that you should never do that and all unit tests should be independent. What about testing where you have some state data. In my case I am testing a class that performs CRUD data operations on a database. I want to test that the class first inserts a record, updates a record, deletes a record etc. It seems reasonable to test writing the record, updating the same record, and then deleting a record as a way of confirming that the crud operations are working. Any thoughts?

user3930061
  • 47
  • 1
  • 3

1 Answers1

0

I think I found the correct answer to this which is to use database mocking. See existing stack overflow article:

How to unit test an object with database queries

user3930061
  • 47
  • 1
  • 3