Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jimporter/mettle
A C++20 unit test framework
https://github.com/jimporter/mettle
c-plus-plus unit-testing
Last synced: 19 days ago
JSON representation
A C++20 unit test framework
- Host: GitHub
- URL: https://github.com/jimporter/mettle
- Owner: jimporter
- License: bsd-3-clause
- Created: 2014-03-15T17:01:37.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2024-08-16T16:32:34.000Z (4 months ago)
- Last Synced: 2024-11-13T19:05:08.720Z (29 days ago)
- Topics: c-plus-plus, unit-testing
- Language: C++
- Homepage: https://jimporter.github.io/mettle
- Size: 3.62 MB
- Stars: 122
- Watchers: 9
- Forks: 12
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
- AwesomeCppGameDev - mettle
README
# mettle
[![Latest release][release-image]][release-link]
[![Documentation][documentation-image]][documentation-link]
[![Build status][ci-image]][ci-link]**mettle** is a "batteries included" unit testing framework for C++20. 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:```c++
#include
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](LICENSE).
[release-image]: https://img.shields.io/github/release/jimporter/mettle.svg
[release-link]: https://github.com/jimporter/mettle/releases/latest
[documentation-image]: https://img.shields.io/badge/docs-mettle-blue.svg
[documentation-link]: https://jimporter.github.io/mettle/
[ci-image]: https://github.com/jimporter/mettle/actions/workflows/build.yml/badge.svg
[ci-link]: https://github.com/jimporter/mettle/actions/workflows/build.yml?query=branch%3Amaster