Testing

R8 supports unit testing using the r8-testing package. To add your own tests you shall create a new testing config as well as adding your tests. The r8-testing package will look for tests in the tests folder in your app root. If you want your tests to be in another directory you may add another source-path to your config file.

Create a config-tests.yml to be the config file used when running tests.

inherit: config.yml
packages:
- r8-testing

Then create a tests foder in the root of your project and add a new test file.

cd my-game
mkdir tests
touch tests/sword_test.cc

Write the tests for the Sword class iside sword_test.cc.

#include <r8/testing/test.h>
#include <sword.h>

TEST(Sword, Shrapness) {
    Sword sword;
    ASSERT(sword.getSharpess() == 100);
}

To run the tests you must prepare your app with the testing config, build it and the run it.

r8 prepare --config ./conig-tests.yml
r8 build

You may now run the binary from the _bin folder.