Skip to content

How to add and run unit tests?

Ahmed Yakout edited this page Apr 21, 2018 · 3 revisions

We use catch2 framework for unit testing integrated with CMake, so you can easily run the tests using ctest or make test commands.

Travis run all the tests remotely, to make sure no commits have broken the code.

To run the tests locally:

mkdir build; cd build; cmake ..; make
make test # or ctest
# to run specific test
ctest -R [test name]

To add new test just go to the tests folder and go for the module you want to add the new test for, let it be the syntax module for example: Add new TEST_CASE in the file test_1.cpp (you can create new file as will)

simple test:

int add(int a, int b);
TEST_CASE("test FIRST")
{
 REQUIRE(add(1,2) == 3);
}

check catch2 tutorial

Clone this wiki locally