Create Google tests

To create a Google test:

  1. Go to File > New Project > Test Project.
  2. Select Google Test Project > Choose to create a project with boilerplate code for a Google test.
  3. In the Project and Test Information dialog, specify settings for the project and test:

    Project and Test Information dialog in the Google Test Project wizard

    1. In Test framework, select Google Test (shared libraries) to link against Google Test or Google Test (headers only) to include necessary Google Test sources into the project.
    2. In Test suite name, enter a name for the test suite.
    3. In Test case name, enter a name for the test case.
    4. For a shared library test, you can set the path to a Google C++ testing framework installation in Googletest install directory (optional).
    5. For a header-only test, you can set the path to a googletest repository clone in Googletest source directory (optional).
    6. In Build system, select the build system to use for building the project: CMake, qmake, or Qbs.

Qt Creator creates the test in the specified project directory.

For more information about creating Google tests, see the Google Test Primer.

Note: While scanning for tests, the parser takes into account only files that directly or indirectly include gtest/gtest.h. Files that currently will not be built will be ignored.

The parser also finds tests that you define with your own macros if they expand to TEST, TEST_F, or GTEST_TEST, or if they register the tests by calling MakeAndRegisterTestInfo() outside of a function body. Own macros that wrap TEST_P or typed tests are not supported. Test names registered by MakeAndRegisterTestInfo() may contain characters that Google Test interprets as filter syntax: :, -, *, and ?. When running such a test, Qt Creator replaces these characters with the ? wildcard, so other tests in the same test suite whose names differ only at these positions are run as well.

See also How To: Test, Select the build system, and Testing.