Skip to content

Goga1992/mettle

This branch is 52 commits behind jimporter/mettle:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

91fe896 · Jul 1, 2023
Jul 1, 2023
Jun 2, 2023
Jul 2, 2016
May 21, 2023
Jun 1, 2023
May 21, 2023
May 29, 2023
Nov 30, 2022
Aug 13, 2015
Dec 24, 2016
Nov 18, 2022
Jan 24, 2023
Jun 2, 2023
Jun 1, 2023
Jan 24, 2023
May 25, 2023
Jun 4, 2023

Repository files navigation

mettle

Latest release Documentation Build status

mettle is a "batteries included" unit testing framework for C++17. Its mission is to provide a full toolbox to address your testing needs and to look good doing it.

Features

Build your own assertions

Expectations (assertions) are defined using composable matchers that automatically generate human-readable output, ensuring even complex objects are easy to test.

Nest your tests

Suites group your tests together and can be nested as deeply as you need, so you can use their hierarchy to set up and tear down your fixtures for you.

Don't repeat yourself

Type- and value-parameterized tests let you write your tests once and apply them to multiple implementations or preconditions.

Aggregate everything

The mettle unified test runner makes it a snap to write multiple, independent test files – even ones running completely different kinds of tests – and aggregate them into a single list of results.

A Brief Example

A picture is worth a thousand words, and code's almost as good (I'm sure it's worth at least 100 words), so let's take a look at a test file:

#include <mettle.hpp>
using namespace mettle;

suite<> basic("a basic suite", [](auto &_) {

  _.test("a test", []() {
    expect(true, equal_to(true));
  });

  for(int i = 0; i < 4; i++) {
    _.test("test number " + std::to_string(i), [i]() {
      expect(i % 2, less(2));
    });
  }

  subsuite<>(_, "a subsuite", [](auto &_) {
    _.test("a sub-test", []() {
      expect(true, equal_to(true));
    });
  });

});

License

This library is licensed under the BSD 3-Clause license.

Releases

No releases published

Packages

No packages published

Languages

  • C++ 98.9%
  • Python 1.1%