We’ll quickly overview how we implemented the most basic testing in ProfaneDB, so that contributors can easily increase test coverage.
Random generation & reflection
The idea is very simple: ProfaneDB should test the biggest set of Protobuf schemas.
To do this,
we use a random generator,
that takes care of filling a Protobuf message with random data.
This post on my personal blog shows how I implemented this, and how it can be used for other projects.
Using Boost to perform tests
ProfaneDB uses Boost libraries extensively.
In this case,
Boost.Random
and
Boost.Test.
We can give a look at
marshaller.test.cpp
to see how we use RandomGenerator
to fill our messages.
Macros and adding new tests
The relevant bit for adding new tests shows how we use macros.
Basically we just want to make sure that no exceptions are thrown when marshalling an object.
Simply adding a new line using the macro RANDOM_TEST
we can test for a new message.
Messages are stored
here
and are part of schema
package.