mirror of
https://github.com/catchorg/Catch2.git
synced 2025-07-29 18:27:41 +02:00
Refactored
43
Home.md
43
Home.md
@ -1,43 +1,12 @@
|
||||
# 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 (but primarily implemented in C++) - coded entirely in headers.
|
||||
A version of this page from a purely Objective-C perspective can be found here: [[Catch-for-Objective-C]]
|
||||
CATCH stands for C++ Automated Test Cases in Headers and is a multi-paradigm automated test framework for C, C++ and Objective-C. It is implemented entirely in a set of headers, but is packaged up as a single header for extra convenience.
|
||||
|
||||
## Why do we need yet another 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).
|
||||
|
||||
There are a number of decent C++ unit testing frameworks out there, including (but by no means limited to), [[CppUnit|http://sourceforge.net/apps/mediawiki/cppunit/index.php?title=Main_Page]], [[Aeryn|v]], [[Cute|http://r2.ifs.hsr.ch/cute]], [[Fructose|http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#C.2B.2B]] and [[many more|http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#C.2B.2B]]. So what does CATCH bring to the party that differentiates it from these? 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" and you're away.
|
||||
* Minimal dependencies - just C++03 with basic STL.
|
||||
* Write test cases as functions or methods.
|
||||
* All test cases are self registering (even for methods).
|
||||
* Failures can (optionally) break into the debugger on Windows and Mac.
|
||||
* 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++ 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.
|
||||
* Objective-C friendly (early stages)
|
||||
* 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
|
||||
## Finding out more about CATCH
|
||||
This wiki serves as the documentation for the framework. Here are some useful pages to get you started:
|
||||
* [[Why do we need yet another C++ Unit Test System?|https://github.com/philsquared/Catch/wiki/Why-yet-another-automated-test-framework%3F]]
|
||||
* [[tutorial]]
|
||||
|
||||
## 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]].
|
||||
CATCH has been classified as, "developer preview" for about a year and a half now, at time of writing. It has proven fairly stable and is in use in some demanding projects. I'm hesitant to drop the "developer preview" status, though, as I'm still planning to make some potentially interface breaking changes in the near future. If I do that I will add a backwards compatibility layer to ease the transition.
|
||||
|
Reference in New Issue
Block a user