7
7
700ghz2018-11-23 19:36:11
API
700ghz, 2018-11-23 19:36:11

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 answer(s)
S
sim3x, 2018-11-23
@700ghz

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.
The "final" tests should take place on the software and environment that will be in production.
It is also desirable to run tests again not on an empty database, but on depersonalized data from a real project
Understand the differences between functional / acceptance tests and unit tests

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question