Making DAO tests run

From OpenNMS
Jump to: navigation, search

The DAO tests require postgres server to be installed on the box that you want to run the tests on.

Some of the tests need to use psql. If a test fails and it complains about not being able to find psql: In Eclipse, right click on the test, select Run - Run. Click the Arguments tab in the VM arguments section add -Dpsql.command="/full/path/to/psql".

These tests are hardcoded to use psql to connect to the Unix domain socket, database test, username opennms, no password, so you should set up pg_hba.conf to use password or trust authentication for Unix domain connections.

Other tests need to know the username and password for the Postgres superuser account on 127.0.0.1. The defaults are "postgres" and "", but you can override this by adding VM arguments: -Dmock.db.adminUser=opennms -Dmock.db.adminPassword=opennms. (You must set up pg_hba.conf to use password or trust authentication for connections from 127.0.0.0.1.)

This command runs all tests from the command line:

../compile.pl --enable-tests test -Dmock.db.adminUser=opennms -Dmock.db.adminPassword=opennms 2>&1 | tee log.txt

You can run only the tests in a subdirectory (like opennms-dao) by changing into it and running:

../compile.pl --enable-tests test

You can run one specific test case:

../compile.pl --enable-tests test -Dtest=TriggerTest