AppCode 2020.3 Help

Perform tests

Generally, AppCode runs and debugs tests in the same way as other applications, by running the run/debug configurations you have created. When doing so, it passes the specified test classes or methods to the test runner.

In many cases, you can initiate a testing session from a context menu. For this purpose, the Run and Debug commands are provided in certain context menus. For example, these commands are available for files containing tests in the Project tool window. They are also available for a test class or method you are currently working on in the editor.

Each running configuration gets its own tab in the Run tool window (the Test Results tab ). One tab can aggregate several tests.

Run or debug a test

  • Use the ⌃⇧F10 and ⌃⇧D shortcuts:

    1. Place the caret at the test class or method that you want to run or debug.

    2. Press ⌃⇧F10/ ⌃⇧D to run/debug the selected class or method.

    AppCode will run/debug the selected class or method using the automatically created temporary run/debug configuration.

  • Use the main toolbar:

    1. Select the necessary run/debug configuration from the list on the main toolbar.

      Select test configuration

      Press ⌥⇧F10 to see the list of available run configurations or ⌥⇧F9 for debug configurations.

    2. Click Run Run or Debug Debug to the right of the list. Alternatively, press ⇧F10/ ⇧F9 to run/debug the selected configuration.

  • Use a context menu:

    • Right-click a test file in the Project tool window or open it in the editor, and right-click the background. From the context menu, select Run... or Debug....

    • For a test method, open the class in the editor and right click anywhere in the method. The context menu suggests the command Run / Debug <method name>.

  • Use gutter icons:

    Click Run test icon to run a single test, or Run all test from the test suite icon to run all tests from the suite (fixture, in case of Google Test):

    Gutter icons for running tests

You can repeat your test session, or individual tests without leaving your test runner tab of the Run tool window. The tests are performed again using the same run configuration as in the initial run.

Rerun a testing session

  • Press ⌃F5 or click Rerun the test on the toolbar of the Test Runner tab.

Rerun an individual test

  • In the Test Runner tab, click a test case node or a test and select Run <test target> on its context menu.

Rerun failed tests

  • In the Test Runner tab, click Rerun Failed Tests button on the toolbar.

Debug a failed test

  1. In the Test Runner tab, press Shift and click Rerun Failed Tests Rerun failed test.

  2. Select Debug from the Restart Failed Tests popup.

    The tests that have failed will rerun in the debug mode.

Terminate tests

You can abort a test session at any point, and all the tests that are currently running will stop immediately.

To stop a test session, click the stop button Icons actions suspend on the toolbar of the test runner, or press ⌃F2.

    Last modified: 10 March 2021