[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Moving toward an improved database testing tool

Hi all,

In the recent days, we decided to improve the testing possibilities for our database. The previous relied on tables we maintained in the database and lacked an easy integration with the Perl testing tool we use for BDD tests.
After discussion with Erik, we deciced to move to pgTAP (http://pgtap.org/). As documented on their site, "pgTAP is a suite of database functions that make it easy to write TAP-emitting unit tests in psql scripts or xUnit-style test functions. The TAP output is suitable for harvesting, analysis, and reporting by a TAP harness, such as those used in Perl applications."

The installation is well documented. For us, the only added requirement was TAP::Parser::SourceHandler::pgTAP, a source handler for pgTAP *.pg files.

We moved all database tests to the new framework.
That involved converting sql/modules/test/*.sql to xt/42-*.pg and removing xt/43-dbtests.t

This added a total of 321 new tests, splitted like this:
  • xt/42-account.pg: 43
  • xt/42-admin.pg: 35
  • xt/42-business-type.pg: 2
  • xt/42-cogs-fifo.pg: 14
  • xt/42-company.pg: 48
  • xt/42-draft.pg: 10
  • xt/42-endofyear.pg: 11
  • xt/42-payment-fx.pg: 10
  • xt/42-payment.pg: 32
  • xt/42-pnl.pg: 14
  • xt/42-reconciliation.pg: 22
  • xt/42-report.pg: 12
  • xt/42-roles.pg: 28
  • xt/42-session.pg: 11
  • xt/42-system.pg: 2
  • xt/42-taxform.pg: 11
  • xt/42-voucher.pg: 16
pgTAP can be integrated directly in prove calls, like we did:
    prove --source Perl
          --ext=.t --ext=.pg
          --source pgTAP   --pgtap-option dbname=lsmb13installtest
                           --pgtap-option username=postgres
                           --pgtap-option suffix=.pg
          t/ xt/

Or you can use pg_prove, providing the proper access for the database.


Yves Lavoie,
LedgerSMB develoment team member

Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
Ledger-smb-devel mailing list