3 ms·
This looks hella good, I particularly am intrigued by the nested setup/teardown system. The natural assert syntax is interesting, too, amazing what macros can
by rdw 12y ago
This looks hella good, I particularly am intrigued by the nested setup/teardown system. The natural assert syntax is interesting, too, amazing what macros can accomplish.
Appropriately, the first question that came to mind was, "what's the catch?" :)
- tbrock 12y agoYup. I found it interesting after a co-worker pointed it out to me because it looks and works kind of like RSpec. We are currently considering using it for a new project and it seems mature enough to give it a go. 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.
- wichert 12y agoFWIW I've been using Catch for a few years now, and I find it mature enough for real world usage.
- tbrock 12y agoGood to know, thanks!
- rdw 12y agoThe biggest turnoff to me is the sheer quantity of code (regardless of the fact that it can all be crammed into a single header file). It seems much more difficult to fix a bug in it than in something like UnitTest++. 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.
- andralex 12y agoThe macro trick is at https://github.com/philsquared/Catch/blob/785db43bb2cd64bfe795ba1c6adef8b82b85430d/include/internal/catch_capture.hpp#L31 https://github.com/philsquared/Catch/blob/785db43bb2cd64bfe7...: planting the tested expression to the right of an operator ->*, which is overloadable and allows for changing the type of the left hand side in the comparison. The rest is a "simple matter of programming". Clever but probably a bit cute - errors would look weird if the expression isn't set up as expected.
- ximeng 12y agoAlso uses template to overload operator ->* https://github.com/philsquared/Catch/blob/785db43bb2cd64bfe795ba1c6adef8b82b85430d/include/internal/catch_result_builder.h https://github.com/philsquared/Catch/blob/785db43bb2cd64bfe7...