AppCode 2016.2 Help

Generating Code in Unit Tests

You can use the Code Generation feature to assist you with test cases. For OCUnit, XCTest, or Google Test, it can help you quickly create SetUp, TearDown, or Test methods:

AppCode_GenerateUT1

For Kiwi, use it to create it, context, beforeEach, afterEach, and specify blocks:

AppCode_GenerateUT2

You can also use a Kiwi Live Template to generate Kiwi Spec.

For Google Test, AppCode offers you a variety of TEST macros:

  • TEST()
  • TEST_F()
  • TEST_P()
  • TYPED_TEST()
  • TYPED_TEST_P()

You can generate a TEST() macro and after you specify a suite name, AppCode will change this macro to the correct one automatically.

To create code constructs using Generate menu

  1. Open the file where you are going to generate code and place the caret at the corresponding position.
  2. On the main menu, choose Code | Generate. Alternatively, right-click the editor and choose Generate on the context menu, or press ⌘N.
  3. In the Generate menu that is displayed in the editor, select the desired construct.
  4. Depending on the selected item, AppCode either inserts the construct immediately or shows a dialog for additional input.

See Also

Last modified: 20 July 2016