Logging and confirming the first message
Now that we have a project ready, we can begin writing some tests and designing the logging library. We already created an empty unit tests file called Construction.cpp
. I like to start with some simple tests that ensure classes can be constructed. We can also use this to make sure that simple functions can be called. This section will focus on creating a single test to log our first message and confirm that it all works.
We already have the log
function from earlier, which opens a file and appends a message. Let’s add a test that calls log
and writes something. The following example shows how to edit Construction.cpp
to add the first test:
#include "../Log.h"
#include <MereTDD/Test.h>
TEST("Simple message can be logged")
{
MereMemo::log("simple");
}
Because we’re testing the logging library, we need to include Log.h
, which is found in the parent directory where...