Updated Tutorial (markdown)

philsquared
2012-06-02 10:49:48 -07:00
parent 5131261120
commit 1003b22cbb

@@ -89,4 +89,7 @@ Although this was a simple test it's been enough to demonstrate a few things abo
1. All we did was #define one identifier and #include one header and we got everything - even an implementation of main() that will [respond to command line arguments](https://github.com/philsquared/Catch/wiki/Command-line). You can only use that #define in one implementation file, for (hopefully) obvious reasons. Once you have more than one file with unit tests in you'll just #include "catch.hpp" and go. Usually it's a good idea to have a dedicated implementation file that just #include's "catch.hpp" with CATCH_CONFIG_MAIN #defined. You can also provide your own implementation of main and drive Catch yourself (see [[Supplying-your-own-main()]]).
2. We introduce test cases with the TEST_CASE macro. This macro takes two arguments - a hierarchical test name (forward slash separated, by convention) and a free-form description. The test name should be unique - and ideally will logically group related tests together like folders in a file system. You can run sets of tests by specifying a wildcarded test name.
3. The name and description arguments are just strings. We haven't had to declare a function or method - or explicitly register the test case anywhere. Behind the scenes a function with a generated name is defined for you, and automatically registered using static registry classes. By abstracting the function name away we can name our tests without the constraints of identifier names.
4. We write our individual test assertions using the REQUIRE macro. Rather than a separate macro for each type of condition we express the condition naturally using C/C++ syntax. Behind the scenes a simple set of expression templates captures the left-hand-side and right-hand-side of the expression so we can display the values in our test report. As we'll see later there _are_ other assertion macros - but because of this technique the number of them is drastically reduced.
4. We write our individual test assertions using the REQUIRE macro. Rather than a separate macro for each type of condition we express the condition naturally using C/C++ syntax. Behind the scenes a simple set of expression templates captures the left-hand-side and right-hand-side of the expression so we can display the values in our test report. As we'll see later there _are_ other assertion macros - but because of this technique the number of them is drastically reduced.
## Next steps
For more specific information see the [[Reference]] pages