Next: How do I add a new test?, Previous: What are unit tests?, Up: Unit tests
Marsyas uses the GPLed Cxxtest (http://cxxtest.sourceforge.net/) testing framework. Cxxtest is a JUnit/CppUnit/xUnit-like framework for C++. We chose Cxxtest because it is lightweight, easy-to-use, is very portable and is distributed under the GPL licence. It is easier to use than other C++ testing frameworks and features a very rich set of assertions.
An example can be found in marsyas/src/tests/unit_tests/TestSelector.h
#include "Selector.h"
using namespace Marsyas;
class Selector_runner : public CxxTest::TestSuite
{
public:
void
setUp()
{
// ... setup the "in" realvec ...
}
void test_all_input_copied_to_output_by_default(void)
{
selector->myProcess(in,out);
TS_ASSERT_EQUALS(out(0,0), 0.1);
}
}
In this example, we setup the input realvec “in” in the function “setup()”. We then add a test by creating a new method that begins with the word “test_”.