martinmoene / lest

A modern, C++11-native, single-file header-only, tiny framework for unit-tests, TDD and BDD (includes C++98 variant)
Boost Software License 1.0
390 stars 45 forks source link

Documentation: Why write it? #12

Open DarrenCook opened 9 years ago

DarrenCook commented 9 years ago

I started using Catch recently, and then saw this library mentioned somewhere. In the Readme you describe it as based on the ideas of Catch. It would be useful to see some kind of comparison with Catch, such as "it is like Catch (as of version 1.1) but adds XXX and YYY. On the downside it doesn't have ZZZ of Catch, and Catch compiles more quickly".

Unless it was a personal exercise in writing a unit test framework, I assume there is an XXX and YYY? :-)

martinmoene commented 9 years ago

Hi Darren,

That's a nice angle to provide more context to lest. To answer some of it now/here:

It started as a personal exercise with C++11 lambda-based tests when I encountered the tests for optional by Andrzej Krzemieński. I already had been following the development of C++98 Catch, had been porting it to VC6 and wondered how C++11 would affect writing a tiny test framework that incorporates ideas from Kevlin Henney found in Catch such as the expression-decomposing assertion macros.

So C++11, lambdas and tiny where the drivers to write lest. I wanted lest to be small enough to be read in a few minutes to show how a simple test framework may look like and to make it easy to grasp how expression-decomposition may work.

Test failure reporting of lest is also different from the one Catch uses at default: I preferred a compiler-like reporting on a single line. In line with this, I contributed the compact reporter to Catch.

During lest's lifetime, focus has shifted to making it more usable, e.g. by including several commandline options that Catch provides.

As I'm also still working with VC6, creating a (less capable) version of lest for C++98/C++03 followed. Further I added automatic test registration to C++11 lest as found in Catch and C++98/03 lest for 1) compatibility and 2) quicker compilation.

As with Catch, I like to use (uppercase) macros instead of C++11 constructs as that visually separates test framework code from code of the actual test.

Hopefully this answers your question. I'll think about how I can incorporate some of this into the lest's Readme.