Answer the question
In order to leave comments, you need to log in
Do I need to clear the DB before every test (TDD/BDD)?
Hello! :)
I write tests for API. The tests make an HTTP request to the endpoints and check the response.
I heard that every test should be isolated .
1. Does this mean that I need to clear the database after each test?
2. What is the best way to fill the database: call the function fillBdTestRecords () (the function fills all tables at once with some text records) before each test? Or not fill the entire database at once, but create only the necessary records (for example, a couple of users) right inside the test?
3. Is it true that the test database should be stored in memory? (not in a file like a regular db) (i.e. use sqlite for tests, instead of mysql)
Thank you in advance!
Answer the question
In order to leave comments, you need to log in
1. Does this mean that I need to clear the database after each test?Yes
2. What is the best way to fill the database: call the function fillBdTestRecords() (the function fills all tables at once with some text records) before each test? Or not fill the entire database at once, but create only the necessary records (for example, a couple of users) right inside the test?create only necessary records (for example, a couple of users) right inside the test
3. Is it true that the test database should be stored in memory? (not in a file like a regular db) (i.e. use sqlite for tests, instead of mysql)desirable, but not required.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question