Getting StartedΒΆ

Download the single header latest release of the single header, MosquitoNet.h from here. Everything you’ll need is in the Enhedron::Test namespace. In the same directory as MosquitoNet.h, create a file Harness.cpp with this code in it:

#include "MosquitoNet.h"

int main(int argc, const char* argv[]) {
    return Enhedron::Test::run(argc, argv);
}

Then compile it with g++ (version 5 or later, but 4.9 will work with –std=c++1y):

g++ --std=c++14 -o test-harness Harness.cpp

Now run ./test-harness and you should get this output:

Totals: 0 tests, 0 checks, 0 fixtures

Let’s add a simple test. We’ll just check the value of a variable. In the same directory again, create a file MinimalTest.cpp so it contains:

#include "MosquitoNet.h"

#include <vector>

using namespace Enhedron::Test;
using std::vector;

static Suite u("a minimal test suite",
    given("a very simple test", [] (auto& check) {
        int a = 1;

        check(VAR(a) == 1);
    })
);

and compile it with:

g++ --std=c++14 -o test-harness MinimalTest.cpp Harness.cpp