Running Epic tests

Test names, modules, and results

Epic includes a testnames VIEW to see all known tests. Any FUNCTION in the test schema whose names starts with "test_" is included:

testdb=# SELECT * FROM test.testnames;
                     name          |      module
-----------------------------------+-------------------
 test_inner_trans_set_active       | test_transactions
 test_inner_trans_set_create       | test_transactions
 test_inner_count_users_by_login   | test_users
(3 rows)

When you run an Epic test using run_test, run_module, or run_all, the result is stored in a table (called test.results), and the appropriate rows are returned to you. If you get busy doing other things, you can always go back and read directly from that table to see which tests passed.

Run a single test

Because you made the effort to RAISE EXCEPTION even if the test passes, it's safe to run any of these tests directly:

testdb=# SELECT * FROM test.test_inner_trans_set_create();
ERROR:  [OK]

Since all Epic tests MUST raise an exception, you'll always get one when running tests this way. It's a good way to work when you're writing a test, because you can see the tracebacks as you go.

You can also run any test individually via:

testdb=# SELECT * FROM test.run_test('test_inner_trans_set_create');
                     name        |      module       | result | errcode |                             errmsg
---------------------------------+-------------------+--------+---------+---------------------------------------------------------------
 test_inner_trans_set_create     | test_transactions | [OK]   |         |
(1 row)

Using run_test, you get an [OK] or [FAIL] response instead of an exception. You also get an entry in test.results, so if you fix a single test, you can update its success without having to run a whole set of tests you didn't modify.

Run a group of tests

If you'd like to run multiple tests together, use module names to group them, and call test.run_module(modulename):

testdb=# SELECT * FROM test.run_module('test_transactions');
                     name    |      module       | result | errcode | errmsg
-----------------------------+-------------------+--------+---------+--------
 test_inner_trans_set_active | test_transactions | [OK]   |         |
 test_inner_trans_set_create | test_transactions | [OK]   |         |
(2 rows)

Run all tests

If you want to run all tests without regard to module, call test.run_all():

testdb=# SELECT * FROM test.run_all();
                     name        |      module       | result | errcode |                             errmsg
---------------------------------+-------------------+--------+---------+---------------------------------------------------------------
 test_inner_trans_set_active     | test_transactions | [OK]   |         |
 test_inner_trans_set_create     | test_transactions | [OK]   |         |
 test_inner_count_users_by_login | test_users        | [FAIL] | 42883   | function inner.count_users_by_login("unknown") does not exist
(3 rows)

If you want the complete CONTEXT, etc. for the [FAIL] above, run the test directly and you'll get the normal traceback, etc. from PL/pgSQL.