Essential to any software quality control process is unit testing: isolating each piece of a system and hitting it with all manner of valid and invalid input values to check for all of the following:
Such tests should be run on all of Mixxx after every code change, as this also finds unintended interactions or consequences of a change. Our build servers will be configured to do this automatically and will fail a build if a test fails.
To manually run the existing tests on your copy of Mixxx (required before final submission of patches or branch merge proposals,) do the following:
scons test=1$ ./mixxx-test $ ./mixxx-test –gtest_filter=MyTest*We require that any new code classes have tests written for them as well in order to consider the code for inclusion into Mixxx.
Mixxx uses the Google C++ Testing Framework. If it's new to you, read the primer.
Make sure to read this section of the Advanced testing guide on floating point comparison. It is very important for writing Mixxx audio tests.
After you understand how it works, do the following:
classname_test.cppMocking is an advanced technique for testing code. Say you have two classes, Foo and Bar. If Foo relies on calling methods of Bar, then using traditional unit testing methods you can't test Foo without also testing Bar. Mocks allow you to solve this problem by creating a mock of Bar. Using a mocking framework, you create a MockBar class which returns arbitrary data.
For mocking, we use the Google Mock framework. It integrates very well with Google Test. To see an example of mocking in action, see the EngineMaster tests in src/test/enginemastertest.cpp. The Mocking For Dummies guide on the Google Mock wiki is great for learning more about mocking, dependency injection, and other advanced testing techniques.