Destroyed What's the CATCH? (markdown)

philsquared
2012-06-02 10:41:00 -07:00
parent 861293a8b9
commit 8463d91b52

@ -1,49 +0,0 @@
# What's the CATCH?
CATCH stands for C++ Adaptive Test Cases in Headers and is a multi-paradigm unit test framework for C, C++ and Objective-C - coded entirely in headers.
This page is presented from an Objective-C perspective. [[For the C++ oriented page see here|https://github.com/philsquared/Catch/wiki]].
## Why do we need yet another Objective-C Unit Test System?
Good question. In fact the working title for CATCH was YACUTS (Yet Another C++ Unit Test System) - followed, briefly, by NINJA CUTS ( NINJA CUTS Is Not Just Another C++ Unit Test System). (CATCH is implemented in C++, hence the C++ bias in those names. The Objective-C bindings, however, give you a blend of the best that C++ and Objective-C have to offer).
Although there are others, Objective-C unit testing is dominated by OCUnit - especially since Apple started bundling it. While OCUnit is a perfectly fine unit test framework, it has some limitations - and doesn't seem to be actively been developed.
So what does CATCH bring to the party that differentiates it? Apart from a Catchy name, of course.
Here's a list of core features of Catch that, collectively, make Catch stand out:
* Implemented entirely in headers. Just #include "catch.hpp" (or #import, if you prefer) and you're away.
* No external dependencies.
* Write test cases as standalone functions or Objective-C methods.
* All test cases are self registering.
* Failures can (optionally) break into the debugger.
* No context to pass around. Call through non test code and back into test code and assertions still work (useful for mocks)
* Only one core assertion macro for comparisons. Standard C/C++/Objective-C operators are used for the comparison - yet the full expression is decomposed and lhs and rhs values are logged.
* Tests are named hierarchically and can be run by matching the entire name or partially to provide one way of grouping tests.
* Test cases can also be tagged and non hierarchical suites can be created from tags (coming soon).
* Test case function names are generated within the macro - you only need to provide a test name (and description)
* Floating point tolerance comparisons are built in using an expressive Approx() syntax.
* Test cases can be described from a TDD or BDD mindset, with support for nested SECTIONs in the latter.
* Output is through reporter objects. basic textual and XML reporters are included. Custom reporters can easily be added.
* JUnit xml output is supported for integration with third-party tools, such as CI servers.
* Output can be to any stream.
* A default main() function is provided (in a header), but you can supply your own for complete control (e.g. integration into your own test runner GUI).
* A command line parser is provided and can still be used if you choose to provided your own main() function.
* Catch can test itself.
* Alternative assertion macro(s) report failures but don't abort the test case
* Internal and friendly macros are isolated so name clashes can be managed
* seamlessly test Objective-C, C, C++ and Objective-C++ code using idioms appropriate to the language under test.
## So is it C++ or Objective-C?
Catch is primarily implemented in C++. This allows it to offer the expressive decomposition of conditional expressions while keeping the syntax uncluttered and natural - as well as a number of other benefits (such as type specific logging - even for C structs).
To allow C++ to be mixed with an Objective-C project your test case source files must be compiled as Objective-C++. This is as simple as making the file extension .mm instead of .m (although there are alternative compiler options). The rest of your project can remain safely as standard .m Objective-C files. *Only the test code needs to be Objective-C++*.
## What state is CATCH in - can I use it now?
Currently CATCH should be considered a "developer preview". You can try it out and see what you think but it is still undergoing heavy development and names and interfaces are subject to change (the macro names should be stable now). I wouldn't recommend it for commercial projects - or anything beyond small scale test projects for now.
of course if you want to contribute then you are very welcome.
## So how do I use it?
Check out the [[tutorial]].