Warning: Can't synchronize with the repository (Unsupported version control system "svn". Check that the Python support libraries for "svn" are correctly installed.)

Welcome to epictest.org

Epic is a unittest framework for PostgreSQL stored procedures. It requires PG 8.1 or higher.

Epic provides PL/pgSQL library functions to help write, run, and manage tests.

Another xUnit-style tool you might try is PGUnit. If you'd like more of a scripting or mixed style try pgTAP; it also integrates with enterprise TAP systems well.

Quick Facts

  • Epic tests are safe: transaction rollbacks are required in every test.
  • Epic tests are simple: write and run your tests in the same language as the functions under test.
  • Epic tests are small: reduce the amount of code in your tests, making them more readable and maintainable.
  • Epic tests are scoped: run tests individually, in groups, or all at once.
  • Epic tests are schema'd: import and execute tests in dev, then DROP SCHEMA test when you're ready for production.



BranchStatus What's New Upgrading Browse Source
1.0 1.0 alpha source:trunk


CREATE OR REPLACE FUNCTION test.test_inner_set_user_state() RETURNS VOID AS $$
-- module: test_users
  v_user_id   integer;
  v_user_rec  users%ROWTYPE;
  -- Create dummy records
  INSERT INTO users (login_name) VALUES ('test1') RETURNING user_id INTO v_user_id;
  -- Run the proc
  PERFORM "inner".set_user_state(v_user_id);
  -- The proc MUST set users.state to 'active';
  SELECT INTO v_user_rec * FROM users WHERE user_id = v_user_id;
  PERFORM test.assert_equal(v_user_rec.state, 'active');
  -- ALWAYS RAISE EXCEPTION at the end of test procs to rollback!
$$ LANGUAGE plpgsql;