Developers/Unit Testing

From PartKeepr Wiki
Revision as of 13:58, 16 February 2016 by Felicitus (talk | contribs) (Introduction)
Jump to: navigation, search


Most PartKeepr tests are actually functional tests. Because we do automated testing using Travis CI, you need to specify your test database prior executing phpunit:

# Specifies the database connection to use. Other choices are mysql and pgsql as specified in [ config_test.yml]
export SYMFONY__TESTDB=sqlite 
vendor/bin/phpunit -c app/

You can also specify a test file by appending it to the command line:

vendor/bin/phpunit -c app/ src/PartKeepr/UnitBundle/Tests/Model/UnitTest.php

Since the functional tests use quite some disk I/O, it is recommended that you place your files on a SSD for unit testing (8 seconds vs. several minutes).

Common Issues

Fatal error: Call to undefined method PHPUnit_TextUI_TestRunner::printVersionString()

This might happen if you are using a local PHPUnit installation. You should use the phpunit version installed in


Unable to find file "@PartKeeprFrontendBundle/Resources/public/js/"

Sometimes the cache messes up unit tests, as we are doing functional tests. You should regenerate the environment.