AppCode 2018.1 Help

Catch Tests Support

Basics

Catch is a cross-platform test framework, which you can use now in AppCode. That means you can create Catch test runner configurations that let you specify test names (with wildcards) or tags, see the results of your test runs, hierarchically, in the test runner window, and can re-run failing tests, or the test where the cursor is, with just a single shortcut. You can even run all tests in a source file.

Getting started with Catch

To start using Catch in your projects, follow these simple steps:

  1. Download the latest version of catch.hpp from here.
    Catch is distributed as a single header file, with no external dependencies (beyond the C++03 standard library).

    Alternatively, you can clone the whole Catch repository from GitHub. That will also give you the docs, tests, scripts and source files that get used to build the single include. If you do this you’ll find the single header file in the single_include directory.

  2. Include the header in your test files.

  3. In addition, in exactly one source file you’ll also need to precede the #include with either #define CATCH_CONFIG_MAIN or CATCH_CONFIG_RUNNER. The former instructs Catch to define main() for you, and will take care of parsing command line arguments and exit codes.

    ac includeCatch
    Use the latter identifier if you want to supply your own main(). For more details, refer to Catch documentation page.

  4. Create the test cases. Note that with Catch you don't need to create a "text fixture class", although that is supported too. You can find a lot more useful information about using Catch in our blog post.

Now you can build and and run your test cases. But to take the full advantage of the built-in test runner, create your own specific Catch test run/debug configurations.

Creating Catch test run/debug configuration

To create a Catch test run/debug configuration manually, do the following:

  • In the main menu, select Run | Edit Configurations. In the dialog that opens:
    1. Click add.png on the toolbar or press N/A. Select Catch Test from the list.

    2. For the new Catch test run/debug configuration:
      • Specify its name in the Name text box. This name will be shown in the list of the available run/debug configurations.

      • Select the Tags/Test radio button to run a test for the particular tags or all the tags. Select the Pattern radio button to run all the tests for a particular pattern.

      • Specify the tag names in the tags text box. Note, that this option is available only when the Tags/Test radio button is selected.

      • Select the desired test from the Test drop down list. Note, that this option is available only when one or more tags have been provided.

      • Specify the pattern name in the Pattern text box. Note, that this option is available only when the Pattern radio button is selected.

      • In the Target field, select the desired target from the list of available targets.

      • Specify common run/debug configuration parameters.

      • Apply the changes and close the dialog box.

      ac catchTestConfig

Last modified: 19 September 2019