T
T
troitskyA2017-10-26 17:15:11
Database
troitskyA, 2017-10-26 17:15:11

Is it possible to use direct DB queries in a functional test?

So there is a functional test for the API, which is to check if the query returns the correct number of records selected by certain criteria, with the expected number of records hammered directly into the code. There is a second functional test that checks for example the deletion of a record.
If I run a group of tests and the record deletion test passes first, then the first test will already fail.
The question is, is it correct in a functional test to use direct queries to the database to get the actual expected number of records?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kn0ckn0ck, 2017-10-26
@troitskyA

The root of the problem here is that the basic principle of test automation is violated: test isolation. In other words, no test should interfere with other tests.
Before executing each test, the appropriate preconditions must be provided and there is no need to make direct queries to the database.
For example, if some test checks the number of records, then this number of records must be created in setUp (how is another question). This is the essence of isolation - for each test there is its own (and only) set of data with which tests can do whatever they want and other tests for this are purple.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question