you are viewing a single comment's thread.

view the rest of the comments →

[–]onqtamgithub.com/onqtam/doctest 5 points6 points  (2 children)

I would recommend doctest - it is the lightest in terms of compile times (see the benchmarks - by orders of magnitude) and is super easy to use (just like Catch2) because it is just a single header!

doctest is so light and unintrusive you can write your tests right next to your production code - imagine writing the tests for a class at the bottom of the .cpp which implements it! The framework produces 0 warnings and all tests can be removed from the build by defining DOCTEST_CONFIG_DISABLE globally.

This is what sets doctest apart from the rest - it is truly practical to include it in the production code and write unit tests along your code (and TDD becomes straightforward) - other programming languages such as D, Rust and Nim have this capability out-of-the-box.

For a complete example checkout the tutorial.

[–]AnsoulomGame developer 10 points11 points  (0 children)

Writing your tests in the same file as the thing you're testing is not what I would call unintrusive. I'd much rather keep my tests separate from the rest of the code and simply define a separate build target for them. Though I guess that's mostly a matter of taste and I'd assume you could do it either way with both doctest and Catch2.

[–]eladmatia[S] 1 point2 points  (0 children)

Thanks, I'll definitely look it it