Answer the question
In order to leave comments, you need to log in
How to effectively perform the same type of tests?
A database is written as a project in X language.
For functional tests, we chose Python and Pytest.
You need to write tests for errors that the base should handle - for example, if you run a query like "insert ... 1/0", the base should return an error and code.
I wrote some tests like
def test_zero_division(cursor_fixture):
cur = cursor_fixture
with pytest.raises(<ExceptionClassName>) as e:
cur.execute(query)
assert e.value.pgcode == some_error_code
Answer the question
In order to leave comments, you need to log in
@pytest.mark.parametrize('err, exc', [(1122, ExceptionClass1), (2233, ExceptionClass2)])
def test_zero_division(cursor_fixture, err, exc):
cur = cursor_fixture
with pytest.raises(exc) as e:
cur.execute(query)
assert e.value.pgcode == err
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question