0

What is the command to let the pg_prove run test case and output the result to Junit xml style?

pg_prove -U ubuntu -d $DB database/test/all_database_tests.sql

Can we use --formatter TAP::Formatter::JUnit or --harness TAP::Harness::JUnit to format the output?

jackchen
  • 71
  • 8

1 Answers1

0

Yes, use TAP::Harness::JUnit to format the test result.

JUNIT_OUTPUT_FILE=/tmp/circleci-test-results/all_database_tests_results.xml pg_prove -U ubuntu -d $DB database/test/all_database_tests.sql --verbose --harness TAP::Harness::JUnit

JUNIT_OUTPUT_FILE tell pg_prove where the test result file name and path; --harness TAP::Harness::JUnit tell pg_prove which format of result to output.

Before you install TAP::Harness::JUnit, you might need to install XML::Simple by command sudo cpan XML::Simple and Test::Deep.

the full example is below:

git clone https://github.com/jlavallee/tap-harness-junit.git
git clone https://github.com/rjbs/Test-Deep.git

sudo cpan TAP::Parser::SourceHandler::pgTAP   # Install pg_prove
psql -U ubuntu -d $DB -c "CREATE EXTENSION IF NOT EXISTS pgtap;" #Create pgtap extension;
sudo cpan XML::Simple  #Install XML::Simple
cd Test-Deep && perl Makefile.PL && sudo make && sudo make test && sudo make install
cd tap-harness-junit && perl Build.PL && sudo ./Build && sudo ./Build install
JUNIT_OUTPUT_FILE=/tmp/circleci-test-results/all_database_tests_results.xml pg_prove -U ubuntu -d $DB database/test/all_database_tests.sql --verbose --harness TAP::Harness::JUnit
jackchen
  • 71
  • 8