CHECK(guitar->sound() == sounds::clean);
CPP reference has a nice overview of it: http://en.cppreference.com/w/cpp/language/lambda
UnitTest++ was written by Noel Llopis, is small, tasteful, fast, and supports fixtures (and nested fixtures) via structs and struct inheritance.
Honest question: Why would I use Catch instead?
- adding a custom main() to unittest++ was pretty messy
- unittest++ is not single-header, meaning you have to recompile all flavours everytime you switch toolsets
- that nested sections stuff looks good and readable, so even though it might be doable with unittest++, this really attracts me more
That being said, I would like to hear from the author or anyone else who can compare them. But likely I'm going to use this for the next project just to check it out.
We don't do unit-testing as part of our official development process where I work, so I was looking for something that I could quickly try out and get started with in my spare moments. I read about several frameworks and Catch seemed to fit the bill best.
Looking over the UnitTest++ web site just now it appears to be nearly as easy as Catch, so if I had found it first I probably would have given it a try.
For those not currently doing any unit testing who want to get a feel for what it is all about, I highly recommend Catch as a "my first unit testing framework."
Appropriately, the first question that came to mind was, "what's the catch?" :)
I'm currently toying with writing a JSONReporter so we can use that as an additional test result output format and I agree, so far it seems to be a really well done project.
That said, inline setup/teardown and parsing expressions in asserts seem like such natural ideas, I can't believe I haven't run across frameworks doing them before. I guess the shadow of JUnit is extremely long.
Anyone know of a really good (preferably simple and pragmatic) C++ mocking/stubbing framework to go with this?
Pulling a single unit out of a legacy codebase can be difficult, especially when you don't want to actually move, copy, or modify the source-files; stubbing out the dependencies and writing mock objects to verify your expectations of what the code should be doing are also very time-consuming.
Those are the hard parts of unit testing C++, and I wonder if anyone has found a good way of doing it (with a framework, or just a technique).
It's lightweight, easy to setup for separated tests or built in tests, and simple to use. Doesn't add anything to help with mocking, but you can do that yourself.
EDIT: To followup, I created a C++ template that leverages TUT and binfmtc that I could use to rapidly iterate with. I used it for working out solutions to problems in "Thinking in C++"; it's posted at http://hardcorehackers.com/~npsimons/Template.hh
Definitely gonna give this a try.
Any recommended test runner to go with it?
I started working on something similar a few days ago just as a proof of concept.
I loved the project logo