libretime/docs/TESTING.md
Lucas Bickel 9b3d0c90da mostly run analyzer tests on travis
* [x] regonfigured the build matrix with more php jobs and a separate python job (we can add more python jobs later)
* [x] run tests on travis' trusty beta container (it's closer to what we need anyway)
* [x] install packages needed for analyzer tests in build env
* [x] added docs on how to run nosetests locally
* [x] don't run initctl in analyzer setup so setup can also be used on travis (and add it to the install script directly)
* [x] ignore replaygain checks on travis (it has proven quite impossible to get the needed python-gi module to work in the provided virtualenv)

I tried a lot of solutions to get the replaygain checks to run. I needed to decide that this has gone far enough, maybe someone who is more of a pythonista than me can take a crack at it and get it solved. Even without running those tests on CI/CD there are still plenty others.

This PR only has parts of what are needed for getting python tests running on travis as per #15. I only took a quick shot at anything not analyzer and figured I would not be able to "fix" them without digging a bit deeper (ie. also getting rid of std_err_override).
2017-03-03 20:38:27 +01:00

1.9 KiB

Testing LibreTime

MVC

The MVC tests are based on PHPUnit and may be found in airtime_mvc/tests.

You can run the tests in you working copy as described below or let travis run them for you on pushes.

Prepare environment

PHPUnit will need to be able to access the database and be allowed to create the libretime_test database. On a clean postgresql install this may be set up as follows.

psql -c 'CREATE DATABASE libretime;' -U postgres
psql -c "CREATE USER libretime WITH PASSWORD 'libretime';" -U postgres
psql -c 'GRANT CONNECT ON DATABASE libretime TO libretime;' -U postgres
psql -c 'ALTER USER libretime CREATEDB;' -U postgres

In this case the libretime database is only used for the initial connection over which the libretime_test database is created.

You may need to tweak the exact commands needed to setup postgresql depending on the distro you installed this to. On Ubuntu trusty the above can be acheived as follows.

sudo -u postgres psql -c 'CREATE DATABASE libretime;'
sudo -u postgres psql -c "CREATE USER libretime WITH PASSWORD 'libretime';"
sudo -u postgres psql -c 'GRANT CONNECT ON DATABASE libretime TO libretime;'
sudo -u postgres psql -c 'ALTER USER libretime CREATEDB;'

Install PHPUnit

PHPUnit should have already been installed when you ran composer install.

If you have not done so, now is the time to do so.

Run the tests

# run all tests
cd airtime_mvc/tests
../../vendor/bin/phpunit

# run a subset of tests
../../vendor/bin/phpunit --filter testEditReatingShowInstance 

Python

The python tests are run through nosetest. To prepare your env you should install it.

# Debian/Ubuntu
apt-get install python-nose

# CentOS
yum install -y python-nose

In most cases you need to install deps before the tets can be run.

Airtime Analyzer

cd python_apps/airtime_analyzer
nosetests