CLion 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:


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


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

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

  • TEST()
  • TEST_F()
  • TEST_P()

You can generate a TEST() macro and after you specify a suite name, CLion 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 Alt+Insert.
  3. In the Generate menu that is displayed in the editor, select the desired construct.
  4. Depending on the selected item, CLion either inserts the construct immediately or shows a dialog for additional input.

See Also

Web Resources:

Last modified: 7 March 2015
comments powered by Disqus