You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1431 lines
43 KiB

2 months ago
  1. # Testing Reference
  2. <!--* toc_depth: 3 *-->
  3. This page lists the facilities provided by GoogleTest for writing test programs.
  4. To use them, include the header `gtest/gtest.h`.
  5. ## Macros
  6. GoogleTest defines the following macros for writing tests.
  7. ### TEST {#TEST}
  8. <pre>
  9. TEST(<em>TestSuiteName</em>, <em>TestName</em>) {
  10. ... <em>statements</em> ...
  11. }
  12. </pre>
  13. Defines an individual test named *`TestName`* in the test suite
  14. *`TestSuiteName`*, consisting of the given statements.
  15. Both arguments *`TestSuiteName`* and *`TestName`* must be valid C++ identifiers
  16. and must not contain underscores (`_`). Tests in different test suites can have
  17. the same individual name.
  18. The statements within the test body can be any code under test.
  19. [Assertions](assertions.md) used within the test body determine the outcome of
  20. the test.
  21. ### TEST_F {#TEST_F}
  22. <pre>
  23. TEST_F(<em>TestFixtureName</em>, <em>TestName</em>) {
  24. ... <em>statements</em> ...
  25. }
  26. </pre>
  27. Defines an individual test named *`TestName`* that uses the test fixture class
  28. *`TestFixtureName`*. The test suite name is *`TestFixtureName`*.
  29. Both arguments *`TestFixtureName`* and *`TestName`* must be valid C++
  30. identifiers and must not contain underscores (`_`). *`TestFixtureName`* must be
  31. the name of a test fixture class—see
  32. [Test Fixtures](../primer.md#same-data-multiple-tests).
  33. The statements within the test body can be any code under test.
  34. [Assertions](assertions.md) used within the test body determine the outcome of
  35. the test.
  36. ### TEST_P {#TEST_P}
  37. <pre>
  38. TEST_P(<em>TestFixtureName</em>, <em>TestName</em>) {
  39. ... <em>statements</em> ...
  40. }
  41. </pre>
  42. Defines an individual value-parameterized test named *`TestName`* that uses the
  43. test fixture class *`TestFixtureName`*. The test suite name is
  44. *`TestFixtureName`*.
  45. Both arguments *`TestFixtureName`* and *`TestName`* must be valid C++
  46. identifiers and must not contain underscores (`_`). *`TestFixtureName`* must be
  47. the name of a value-parameterized test fixture class—see
  48. [Value-Parameterized Tests](../advanced.md#value-parameterized-tests).
  49. The statements within the test body can be any code under test. Within the test
  50. body, the test parameter can be accessed with the `GetParam()` function (see
  51. [`WithParamInterface`](#WithParamInterface)). For example:
  52. ```cpp
  53. TEST_P(MyTestSuite, DoesSomething) {
  54. ...
  55. EXPECT_TRUE(DoSomething(GetParam()));
  56. ...
  57. }
  58. ```
  59. [Assertions](assertions.md) used within the test body determine the outcome of
  60. the test.
  61. See also [`INSTANTIATE_TEST_SUITE_P`](#INSTANTIATE_TEST_SUITE_P).
  62. ### INSTANTIATE_TEST_SUITE_P {#INSTANTIATE_TEST_SUITE_P}
  63. `INSTANTIATE_TEST_SUITE_P(`*`InstantiationName`*`,`*`TestSuiteName`*`,`*`param_generator`*`)`
  64. \
  65. `INSTANTIATE_TEST_SUITE_P(`*`InstantiationName`*`,`*`TestSuiteName`*`,`*`param_generator`*`,`*`name_generator`*`)`
  66. Instantiates the value-parameterized test suite *`TestSuiteName`* (defined with
  67. [`TEST_P`](#TEST_P)).
  68. The argument *`InstantiationName`* is a unique name for the instantiation of the
  69. test suite, to distinguish between multiple instantiations. In test output, the
  70. instantiation name is added as a prefix to the test suite name
  71. *`TestSuiteName`*.
  72. The argument *`param_generator`* is one of the following GoogleTest-provided
  73. functions that generate the test parameters, all defined in the `::testing`
  74. namespace:
  75. <span id="param-generators"></span>
  76. | Parameter Generator | Behavior |
  77. | ------------------- | ---------------------------------------------------- |
  78. | `Range(begin, end [, step])` | Yields values `{begin, begin+step, begin+step+step, ...}`. The values do not include `end`. `step` defaults to 1. |
  79. | `Values(v1, v2, ..., vN)` | Yields values `{v1, v2, ..., vN}`. |
  80. | `ValuesIn(container)` or `ValuesIn(begin,end)` | Yields values from a C-style array, an STL-style container, or an iterator range `[begin, end)`. |
  81. | `Bool()` | Yields sequence `{false, true}`. |
  82. | `Combine(g1, g2, ..., gN)` | Yields as `std::tuple` *n*-tuples all combinations (Cartesian product) of the values generated by the given *n* generators `g1`, `g2`, ..., `gN`. |
  83. The optional last argument *`name_generator`* is a function or functor that
  84. generates custom test name suffixes based on the test parameters. The function
  85. must accept an argument of type
  86. [`TestParamInfo<class ParamType>`](#TestParamInfo) and return a `std::string`.
  87. The test name suffix can only contain alphanumeric characters and underscores.
  88. GoogleTest provides [`PrintToStringParamName`](#PrintToStringParamName), or a
  89. custom function can be used for more control:
  90. ```cpp
  91. INSTANTIATE_TEST_SUITE_P(
  92. MyInstantiation, MyTestSuite,
  93. ::testing::Values(...),
  94. [](const ::testing::TestParamInfo<MyTestSuite::ParamType>& info) {
  95. // Can use info.param here to generate the test suffix
  96. std::string name = ...
  97. return name;
  98. });
  99. ```
  100. For more information, see
  101. [Value-Parameterized Tests](../advanced.md#value-parameterized-tests).
  102. See also
  103. [`GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST`](#GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST).
  104. ### TYPED_TEST_SUITE {#TYPED_TEST_SUITE}
  105. `TYPED_TEST_SUITE(`*`TestFixtureName`*`,`*`Types`*`)`
  106. Defines a typed test suite based on the test fixture *`TestFixtureName`*. The
  107. test suite name is *`TestFixtureName`*.
  108. The argument *`TestFixtureName`* is a fixture class template, parameterized by a
  109. type, for example:
  110. ```cpp
  111. template <typename T>
  112. class MyFixture : public ::testing::Test {
  113. public:
  114. ...
  115. using List = std::list<T>;
  116. static T shared_;
  117. T value_;
  118. };
  119. ```
  120. The argument *`Types`* is a [`Types`](#Types) object representing the list of
  121. types to run the tests on, for example:
  122. ```cpp
  123. using MyTypes = ::testing::Types<char, int, unsigned int>;
  124. TYPED_TEST_SUITE(MyFixture, MyTypes);
  125. ```
  126. The type alias (`using` or `typedef`) is necessary for the `TYPED_TEST_SUITE`
  127. macro to parse correctly.
  128. See also [`TYPED_TEST`](#TYPED_TEST) and
  129. [Typed Tests](../advanced.md#typed-tests) for more information.
  130. ### TYPED_TEST {#TYPED_TEST}
  131. <pre>
  132. TYPED_TEST(<em>TestSuiteName</em>, <em>TestName</em>) {
  133. ... <em>statements</em> ...
  134. }
  135. </pre>
  136. Defines an individual typed test named *`TestName`* in the typed test suite
  137. *`TestSuiteName`*. The test suite must be defined with
  138. [`TYPED_TEST_SUITE`](#TYPED_TEST_SUITE).
  139. Within the test body, the special name `TypeParam` refers to the type parameter,
  140. and `TestFixture` refers to the fixture class. See the following example:
  141. ```cpp
  142. TYPED_TEST(MyFixture, Example) {
  143. // Inside a test, refer to the special name TypeParam to get the type
  144. // parameter. Since we are inside a derived class template, C++ requires
  145. // us to visit the members of MyFixture via 'this'.
  146. TypeParam n = this->value_;
  147. // To visit static members of the fixture, add the 'TestFixture::'
  148. // prefix.
  149. n += TestFixture::shared_;
  150. // To refer to typedefs in the fixture, add the 'typename TestFixture::'
  151. // prefix. The 'typename' is required to satisfy the compiler.
  152. typename TestFixture::List values;
  153. values.push_back(n);
  154. ...
  155. }
  156. ```
  157. For more information, see [Typed Tests](../advanced.md#typed-tests).
  158. ### TYPED_TEST_SUITE_P {#TYPED_TEST_SUITE_P}
  159. `TYPED_TEST_SUITE_P(`*`TestFixtureName`*`)`
  160. Defines a type-parameterized test suite based on the test fixture
  161. *`TestFixtureName`*. The test suite name is *`TestFixtureName`*.
  162. The argument *`TestFixtureName`* is a fixture class template, parameterized by a
  163. type. See [`TYPED_TEST_SUITE`](#TYPED_TEST_SUITE) for an example.
  164. See also [`TYPED_TEST_P`](#TYPED_TEST_P) and
  165. [Type-Parameterized Tests](../advanced.md#type-parameterized-tests) for more
  166. information.
  167. ### TYPED_TEST_P {#TYPED_TEST_P}
  168. <pre>
  169. TYPED_TEST_P(<em>TestSuiteName</em>, <em>TestName</em>) {
  170. ... <em>statements</em> ...
  171. }
  172. </pre>
  173. Defines an individual type-parameterized test named *`TestName`* in the
  174. type-parameterized test suite *`TestSuiteName`*. The test suite must be defined
  175. with [`TYPED_TEST_SUITE_P`](#TYPED_TEST_SUITE_P).
  176. Within the test body, the special name `TypeParam` refers to the type parameter,
  177. and `TestFixture` refers to the fixture class. See [`TYPED_TEST`](#TYPED_TEST)
  178. for an example.
  179. See also [`REGISTER_TYPED_TEST_SUITE_P`](#REGISTER_TYPED_TEST_SUITE_P) and
  180. [Type-Parameterized Tests](../advanced.md#type-parameterized-tests) for more
  181. information.
  182. ### REGISTER_TYPED_TEST_SUITE_P {#REGISTER_TYPED_TEST_SUITE_P}
  183. `REGISTER_TYPED_TEST_SUITE_P(`*`TestSuiteName`*`,`*`TestNames...`*`)`
  184. Registers the type-parameterized tests *`TestNames...`* of the test suite
  185. *`TestSuiteName`*. The test suite and tests must be defined with
  186. [`TYPED_TEST_SUITE_P`](#TYPED_TEST_SUITE_P) and [`TYPED_TEST_P`](#TYPED_TEST_P).
  187. For example:
  188. ```cpp
  189. // Define the test suite and tests.
  190. TYPED_TEST_SUITE_P(MyFixture);
  191. TYPED_TEST_P(MyFixture, HasPropertyA) { ... }
  192. TYPED_TEST_P(MyFixture, HasPropertyB) { ... }
  193. // Register the tests in the test suite.
  194. REGISTER_TYPED_TEST_SUITE_P(MyFixture, HasPropertyA, HasPropertyB);
  195. ```
  196. See also [`INSTANTIATE_TYPED_TEST_SUITE_P`](#INSTANTIATE_TYPED_TEST_SUITE_P) and
  197. [Type-Parameterized Tests](../advanced.md#type-parameterized-tests) for more
  198. information.
  199. ### INSTANTIATE_TYPED_TEST_SUITE_P {#INSTANTIATE_TYPED_TEST_SUITE_P}
  200. `INSTANTIATE_TYPED_TEST_SUITE_P(`*`InstantiationName`*`,`*`TestSuiteName`*`,`*`Types`*`)`
  201. Instantiates the type-parameterized test suite *`TestSuiteName`*. The test suite
  202. must be registered with
  203. [`REGISTER_TYPED_TEST_SUITE_P`](#REGISTER_TYPED_TEST_SUITE_P).
  204. The argument *`InstantiationName`* is a unique name for the instantiation of the
  205. test suite, to distinguish between multiple instantiations. In test output, the
  206. instantiation name is added as a prefix to the test suite name
  207. *`TestSuiteName`*.
  208. The argument *`Types`* is a [`Types`](#Types) object representing the list of
  209. types to run the tests on, for example:
  210. ```cpp
  211. using MyTypes = ::testing::Types<char, int, unsigned int>;
  212. INSTANTIATE_TYPED_TEST_SUITE_P(MyInstantiation, MyFixture, MyTypes);
  213. ```
  214. The type alias (`using` or `typedef`) is necessary for the
  215. `INSTANTIATE_TYPED_TEST_SUITE_P` macro to parse correctly.
  216. For more information, see
  217. [Type-Parameterized Tests](../advanced.md#type-parameterized-tests).
  218. ### FRIEND_TEST {#FRIEND_TEST}
  219. `FRIEND_TEST(`*`TestSuiteName`*`,`*`TestName`*`)`
  220. Within a class body, declares an individual test as a friend of the class,
  221. enabling the test to access private class members.
  222. If the class is defined in a namespace, then in order to be friends of the
  223. class, test fixtures and tests must be defined in the exact same namespace,
  224. without inline or anonymous namespaces.
  225. For example, if the class definition looks like the following:
  226. ```cpp
  227. namespace my_namespace {
  228. class MyClass {
  229. friend class MyClassTest;
  230. FRIEND_TEST(MyClassTest, HasPropertyA);
  231. FRIEND_TEST(MyClassTest, HasPropertyB);
  232. ... definition of class MyClass ...
  233. };
  234. } // namespace my_namespace
  235. ```
  236. Then the test code should look like:
  237. ```cpp
  238. namespace my_namespace {
  239. class MyClassTest : public ::testing::Test {
  240. ...
  241. };
  242. TEST_F(MyClassTest, HasPropertyA) { ... }
  243. TEST_F(MyClassTest, HasPropertyB) { ... }
  244. } // namespace my_namespace
  245. ```
  246. See [Testing Private Code](../advanced.md#testing-private-code) for more
  247. information.
  248. ### SCOPED_TRACE {#SCOPED_TRACE}
  249. `SCOPED_TRACE(`*`message`*`)`
  250. Causes the current file name, line number, and the given message *`message`* to
  251. be added to the failure message for each assertion failure that occurs in the
  252. scope.
  253. For more information, see
  254. [Adding Traces to Assertions](../advanced.md#adding-traces-to-assertions).
  255. See also the [`ScopedTrace` class](#ScopedTrace).
  256. ### GTEST_SKIP {#GTEST_SKIP}
  257. `GTEST_SKIP()`
  258. Prevents further test execution at runtime.
  259. Can be used in individual test cases or in the `SetUp()` methods of test
  260. environments or test fixtures (classes derived from the
  261. [`Environment`](#Environment) or [`Test`](#Test) classes). If used in a global
  262. test environment `SetUp()` method, it skips all tests in the test program. If
  263. used in a test fixture `SetUp()` method, it skips all tests in the corresponding
  264. test suite.
  265. Similar to assertions, `GTEST_SKIP` allows streaming a custom message into it.
  266. See [Skipping Test Execution](../advanced.md#skipping-test-execution) for more
  267. information.
  268. ### GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST {#GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST}
  269. `GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(`*`TestSuiteName`*`)`
  270. Allows the value-parameterized test suite *`TestSuiteName`* to be
  271. uninstantiated.
  272. By default, every [`TEST_P`](#TEST_P) call without a corresponding
  273. [`INSTANTIATE_TEST_SUITE_P`](#INSTANTIATE_TEST_SUITE_P) call causes a failing
  274. test in the test suite `GoogleTestVerification`.
  275. `GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST` suppresses this failure for the
  276. given test suite.
  277. ## Classes and types
  278. GoogleTest defines the following classes and types to help with writing tests.
  279. ### AssertionResult {#AssertionResult}
  280. `::testing::AssertionResult`
  281. A class for indicating whether an assertion was successful.
  282. When the assertion wasn't successful, the `AssertionResult` object stores a
  283. non-empty failure message that can be retrieved with the object's `message()`
  284. method.
  285. To create an instance of this class, use one of the factory functions
  286. [`AssertionSuccess()`](#AssertionSuccess) or
  287. [`AssertionFailure()`](#AssertionFailure).
  288. ### AssertionException {#AssertionException}
  289. `::testing::AssertionException`
  290. Exception which can be thrown from
  291. [`TestEventListener::OnTestPartResult`](#TestEventListener::OnTestPartResult).
  292. ### EmptyTestEventListener {#EmptyTestEventListener}
  293. `::testing::EmptyTestEventListener`
  294. Provides an empty implementation of all methods in the
  295. [`TestEventListener`](#TestEventListener) interface, such that a subclass only
  296. needs to override the methods it cares about.
  297. ### Environment {#Environment}
  298. `::testing::Environment`
  299. Represents a global test environment. See
  300. [Global Set-Up and Tear-Down](../advanced.md#global-set-up-and-tear-down).
  301. #### Protected Methods {#Environment-protected}
  302. ##### SetUp {#Environment::SetUp}
  303. `virtual void Environment::SetUp()`
  304. Override this to define how to set up the environment.
  305. ##### TearDown {#Environment::TearDown}
  306. `virtual void Environment::TearDown()`
  307. Override this to define how to tear down the environment.
  308. ### ScopedTrace {#ScopedTrace}
  309. `::testing::ScopedTrace`
  310. An instance of this class causes a trace to be included in every test failure
  311. message generated by code in the scope of the lifetime of the `ScopedTrace`
  312. instance. The effect is undone with the destruction of the instance.
  313. The `ScopedTrace` constructor has the following form:
  314. ```cpp
  315. template <typename T>
  316. ScopedTrace(const char* file, int line, const T& message)
  317. ```
  318. Example usage:
  319. ```cpp
  320. ::testing::ScopedTrace trace("file.cc", 123, "message");
  321. ```
  322. The resulting trace includes the given source file path and line number, and the
  323. given message. The `message` argument can be anything streamable to
  324. `std::ostream`.
  325. See also [`SCOPED_TRACE`](#SCOPED_TRACE).
  326. ### Test {#Test}
  327. `::testing::Test`
  328. The abstract class that all tests inherit from. `Test` is not copyable.
  329. #### Public Methods {#Test-public}
  330. ##### SetUpTestSuite {#Test::SetUpTestSuite}
  331. `static void Test::SetUpTestSuite()`
  332. Performs shared setup for all tests in the test suite. GoogleTest calls
  333. `SetUpTestSuite()` before running the first test in the test suite.
  334. ##### TearDownTestSuite {#Test::TearDownTestSuite}
  335. `static void Test::TearDownTestSuite()`
  336. Performs shared teardown for all tests in the test suite. GoogleTest calls
  337. `TearDownTestSuite()` after running the last test in the test suite.
  338. ##### HasFatalFailure {#Test::HasFatalFailure}
  339. `static bool Test::HasFatalFailure()`
  340. Returns true if and only if the current test has a fatal failure.
  341. ##### HasNonfatalFailure {#Test::HasNonfatalFailure}
  342. `static bool Test::HasNonfatalFailure()`
  343. Returns true if and only if the current test has a nonfatal failure.
  344. ##### HasFailure {#Test::HasFailure}
  345. `static bool Test::HasFailure()`
  346. Returns true if and only if the current test has any failure, either fatal or
  347. nonfatal.
  348. ##### IsSkipped {#Test::IsSkipped}
  349. `static bool Test::IsSkipped()`
  350. Returns true if and only if the current test was skipped.
  351. ##### RecordProperty {#Test::RecordProperty}
  352. `static void Test::RecordProperty(const std::string& key, const std::string&
  353. value)` \
  354. `static void Test::RecordProperty(const std::string& key, int value)`
  355. Logs a property for the current test, test suite, or entire invocation of the
  356. test program. Only the last value for a given key is logged.
  357. The key must be a valid XML attribute name, and cannot conflict with the ones
  358. already used by GoogleTest (`name`, `status`, `time`, `classname`, `type_param`,
  359. and `value_param`).
  360. `RecordProperty` is `public static` so it can be called from utility functions
  361. that are not members of the test fixture.
  362. Calls to `RecordProperty` made during the lifespan of the test (from the moment
  363. its constructor starts to the moment its destructor finishes) are output in XML
  364. as attributes of the `<testcase>` element. Properties recorded from a fixture's
  365. `SetUpTestSuite` or `TearDownTestSuite` methods are logged as attributes of the
  366. corresponding `<testsuite>` element. Calls to `RecordProperty` made in the
  367. global context (before or after invocation of `RUN_ALL_TESTS` or from the
  368. `SetUp`/`TearDown` methods of registered `Environment` objects) are output as
  369. attributes of the `<testsuites>` element.
  370. #### Protected Methods {#Test-protected}
  371. ##### SetUp {#Test::SetUp}
  372. `virtual void Test::SetUp()`
  373. Override this to perform test fixture setup. GoogleTest calls `SetUp()` before
  374. running each individual test.
  375. ##### TearDown {#Test::TearDown}
  376. `virtual void Test::TearDown()`
  377. Override this to perform test fixture teardown. GoogleTest calls `TearDown()`
  378. after running each individual test.
  379. ### TestWithParam {#TestWithParam}
  380. `::testing::TestWithParam<T>`
  381. A convenience class which inherits from both [`Test`](#Test) and
  382. [`WithParamInterface<T>`](#WithParamInterface).
  383. ### TestSuite {#TestSuite}
  384. Represents a test suite. `TestSuite` is not copyable.
  385. #### Public Methods {#TestSuite-public}
  386. ##### name {#TestSuite::name}
  387. `const char* TestSuite::name() const`
  388. Gets the name of the test suite.
  389. ##### type_param {#TestSuite::type_param}
  390. `const char* TestSuite::type_param() const`
  391. Returns the name of the parameter type, or `NULL` if this is not a typed or
  392. type-parameterized test suite. See [Typed Tests](../advanced.md#typed-tests) and
  393. [Type-Parameterized Tests](../advanced.md#type-parameterized-tests).
  394. ##### should_run {#TestSuite::should_run}
  395. `bool TestSuite::should_run() const`
  396. Returns true if any test in this test suite should run.
  397. ##### successful_test_count {#TestSuite::successful_test_count}
  398. `int TestSuite::successful_test_count() const`
  399. Gets the number of successful tests in this test suite.
  400. ##### skipped_test_count {#TestSuite::skipped_test_count}
  401. `int TestSuite::skipped_test_count() const`
  402. Gets the number of skipped tests in this test suite.
  403. ##### failed_test_count {#TestSuite::failed_test_count}
  404. `int TestSuite::failed_test_count() const`
  405. Gets the number of failed tests in this test suite.
  406. ##### reportable_disabled_test_count {#TestSuite::reportable_disabled_test_count}
  407. `int TestSuite::reportable_disabled_test_count() const`
  408. Gets the number of disabled tests that will be reported in the XML report.
  409. ##### disabled_test_count {#TestSuite::disabled_test_count}
  410. `int TestSuite::disabled_test_count() const`
  411. Gets the number of disabled tests in this test suite.
  412. ##### reportable_test_count {#TestSuite::reportable_test_count}
  413. `int TestSuite::reportable_test_count() const`
  414. Gets the number of tests to be printed in the XML report.
  415. ##### test_to_run_count {#TestSuite::test_to_run_count}
  416. `int TestSuite::test_to_run_count() const`
  417. Get the number of tests in this test suite that should run.
  418. ##### total_test_count {#TestSuite::total_test_count}
  419. `int TestSuite::total_test_count() const`
  420. Gets the number of all tests in this test suite.
  421. ##### Passed {#TestSuite::Passed}
  422. `bool TestSuite::Passed() const`
  423. Returns true if and only if the test suite passed.
  424. ##### Failed {#TestSuite::Failed}
  425. `bool TestSuite::Failed() const`
  426. Returns true if and only if the test suite failed.
  427. ##### elapsed_time {#TestSuite::elapsed_time}
  428. `TimeInMillis TestSuite::elapsed_time() const`
  429. Returns the elapsed time, in milliseconds.
  430. ##### start_timestamp {#TestSuite::start_timestamp}
  431. `TimeInMillis TestSuite::start_timestamp() const`
  432. Gets the time of the test suite start, in ms from the start of the UNIX epoch.
  433. ##### GetTestInfo {#TestSuite::GetTestInfo}
  434. `const TestInfo* TestSuite::GetTestInfo(int i) const`
  435. Returns the [`TestInfo`](#TestInfo) for the `i`-th test among all the tests. `i`
  436. can range from 0 to `total_test_count() - 1`. If `i` is not in that range,
  437. returns `NULL`.
  438. ##### ad_hoc_test_result {#TestSuite::ad_hoc_test_result}
  439. `const TestResult& TestSuite::ad_hoc_test_result() const`
  440. Returns the [`TestResult`](#TestResult) that holds test properties recorded
  441. during execution of `SetUpTestSuite` and `TearDownTestSuite`.
  442. ### TestInfo {#TestInfo}
  443. `::testing::TestInfo`
  444. Stores information about a test.
  445. #### Public Methods {#TestInfo-public}
  446. ##### test_suite_name {#TestInfo::test_suite_name}
  447. `const char* TestInfo::test_suite_name() const`
  448. Returns the test suite name.
  449. ##### name {#TestInfo::name}
  450. `const char* TestInfo::name() const`
  451. Returns the test name.
  452. ##### type_param {#TestInfo::type_param}
  453. `const char* TestInfo::type_param() const`
  454. Returns the name of the parameter type, or `NULL` if this is not a typed or
  455. type-parameterized test. See [Typed Tests](../advanced.md#typed-tests) and
  456. [Type-Parameterized Tests](../advanced.md#type-parameterized-tests).
  457. ##### value_param {#TestInfo::value_param}
  458. `const char* TestInfo::value_param() const`
  459. Returns the text representation of the value parameter, or `NULL` if this is not
  460. a value-parameterized test. See
  461. [Value-Parameterized Tests](../advanced.md#value-parameterized-tests).
  462. ##### file {#TestInfo::file}
  463. `const char* TestInfo::file() const`
  464. Returns the file name where this test is defined.
  465. ##### line {#TestInfo::line}
  466. `int TestInfo::line() const`
  467. Returns the line where this test is defined.
  468. ##### is_in_another_shard {#TestInfo::is_in_another_shard}
  469. `bool TestInfo::is_in_another_shard() const`
  470. Returns true if this test should not be run because it's in another shard.
  471. ##### should_run {#TestInfo::should_run}
  472. `bool TestInfo::should_run() const`
  473. Returns true if this test should run, that is if the test is not disabled (or it
  474. is disabled but the `also_run_disabled_tests` flag has been specified) and its
  475. full name matches the user-specified filter.
  476. GoogleTest allows the user to filter the tests by their full names. Only the
  477. tests that match the filter will run. See
  478. [Running a Subset of the Tests](../advanced.md#running-a-subset-of-the-tests)
  479. for more information.
  480. ##### is_reportable {#TestInfo::is_reportable}
  481. `bool TestInfo::is_reportable() const`
  482. Returns true if and only if this test will appear in the XML report.
  483. ##### result {#TestInfo::result}
  484. `const TestResult* TestInfo::result() const`
  485. Returns the result of the test. See [`TestResult`](#TestResult).
  486. ### TestParamInfo {#TestParamInfo}
  487. `::testing::TestParamInfo<T>`
  488. Describes a parameter to a value-parameterized test. The type `T` is the type of
  489. the parameter.
  490. Contains the fields `param` and `index` which hold the value of the parameter
  491. and its integer index respectively.
  492. ### UnitTest {#UnitTest}
  493. `::testing::UnitTest`
  494. This class contains information about the test program.
  495. `UnitTest` is a singleton class. The only instance is created when
  496. `UnitTest::GetInstance()` is first called. This instance is never deleted.
  497. `UnitTest` is not copyable.
  498. #### Public Methods {#UnitTest-public}
  499. ##### GetInstance {#UnitTest::GetInstance}
  500. `static UnitTest* UnitTest::GetInstance()`
  501. Gets the singleton `UnitTest` object. The first time this method is called, a
  502. `UnitTest` object is constructed and returned. Consecutive calls will return the
  503. same object.
  504. ##### original_working_dir {#UnitTest::original_working_dir}
  505. `const char* UnitTest::original_working_dir() const`
  506. Returns the working directory when the first [`TEST()`](#TEST) or
  507. [`TEST_F()`](#TEST_F) was executed. The `UnitTest` object owns the string.
  508. ##### current_test_suite {#UnitTest::current_test_suite}
  509. `const TestSuite* UnitTest::current_test_suite() const`
  510. Returns the [`TestSuite`](#TestSuite) object for the test that's currently
  511. running, or `NULL` if no test is running.
  512. ##### current_test_info {#UnitTest::current_test_info}
  513. `const TestInfo* UnitTest::current_test_info() const`
  514. Returns the [`TestInfo`](#TestInfo) object for the test that's currently
  515. running, or `NULL` if no test is running.
  516. ##### random_seed {#UnitTest::random_seed}
  517. `int UnitTest::random_seed() const`
  518. Returns the random seed used at the start of the current test run.
  519. ##### successful_test_suite_count {#UnitTest::successful_test_suite_count}
  520. `int UnitTest::successful_test_suite_count() const`
  521. Gets the number of successful test suites.
  522. ##### failed_test_suite_count {#UnitTest::failed_test_suite_count}
  523. `int UnitTest::failed_test_suite_count() const`
  524. Gets the number of failed test suites.
  525. ##### total_test_suite_count {#UnitTest::total_test_suite_count}
  526. `int UnitTest::total_test_suite_count() const`
  527. Gets the number of all test suites.
  528. ##### test_suite_to_run_count {#UnitTest::test_suite_to_run_count}
  529. `int UnitTest::test_suite_to_run_count() const`
  530. Gets the number of all test suites that contain at least one test that should
  531. run.
  532. ##### successful_test_count {#UnitTest::successful_test_count}
  533. `int UnitTest::successful_test_count() const`
  534. Gets the number of successful tests.
  535. ##### skipped_test_count {#UnitTest::skipped_test_count}
  536. `int UnitTest::skipped_test_count() const`
  537. Gets the number of skipped tests.
  538. ##### failed_test_count {#UnitTest::failed_test_count}
  539. `int UnitTest::failed_test_count() const`
  540. Gets the number of failed tests.
  541. ##### reportable_disabled_test_count {#UnitTest::reportable_disabled_test_count}
  542. `int UnitTest::reportable_disabled_test_count() const`
  543. Gets the number of disabled tests that will be reported in the XML report.
  544. ##### disabled_test_count {#UnitTest::disabled_test_count}
  545. `int UnitTest::disabled_test_count() const`
  546. Gets the number of disabled tests.
  547. ##### reportable_test_count {#UnitTest::reportable_test_count}
  548. `int UnitTest::reportable_test_count() const`
  549. Gets the number of tests to be printed in the XML report.
  550. ##### total_test_count {#UnitTest::total_test_count}
  551. `int UnitTest::total_test_count() const`
  552. Gets the number of all tests.
  553. ##### test_to_run_count {#UnitTest::test_to_run_count}
  554. `int UnitTest::test_to_run_count() const`
  555. Gets the number of tests that should run.
  556. ##### start_timestamp {#UnitTest::start_timestamp}
  557. `TimeInMillis UnitTest::start_timestamp() const`
  558. Gets the time of the test program start, in ms from the start of the UNIX epoch.
  559. ##### elapsed_time {#UnitTest::elapsed_time}
  560. `TimeInMillis UnitTest::elapsed_time() const`
  561. Gets the elapsed time, in milliseconds.
  562. ##### Passed {#UnitTest::Passed}
  563. `bool UnitTest::Passed() const`
  564. Returns true if and only if the unit test passed (i.e. all test suites passed).
  565. ##### Failed {#UnitTest::Failed}
  566. `bool UnitTest::Failed() const`
  567. Returns true if and only if the unit test failed (i.e. some test suite failed or
  568. something outside of all tests failed).
  569. ##### GetTestSuite {#UnitTest::GetTestSuite}
  570. `const TestSuite* UnitTest::GetTestSuite(int i) const`
  571. Gets the [`TestSuite`](#TestSuite) object for the `i`-th test suite among all
  572. the test suites. `i` can range from 0 to `total_test_suite_count() - 1`. If `i`
  573. is not in that range, returns `NULL`.
  574. ##### ad_hoc_test_result {#UnitTest::ad_hoc_test_result}
  575. `const TestResult& UnitTest::ad_hoc_test_result() const`
  576. Returns the [`TestResult`](#TestResult) containing information on test failures
  577. and properties logged outside of individual test suites.
  578. ##### listeners {#UnitTest::listeners}
  579. `TestEventListeners& UnitTest::listeners()`
  580. Returns the list of event listeners that can be used to track events inside
  581. GoogleTest. See [`TestEventListeners`](#TestEventListeners).
  582. ### TestEventListener {#TestEventListener}
  583. `::testing::TestEventListener`
  584. The interface for tracing execution of tests. The methods below are listed in
  585. the order the corresponding events are fired.
  586. #### Public Methods {#TestEventListener-public}
  587. ##### OnTestProgramStart {#TestEventListener::OnTestProgramStart}
  588. `virtual void TestEventListener::OnTestProgramStart(const UnitTest& unit_test)`
  589. Fired before any test activity starts.
  590. ##### OnTestIterationStart {#TestEventListener::OnTestIterationStart}
  591. `virtual void TestEventListener::OnTestIterationStart(const UnitTest& unit_test,
  592. int iteration)`
  593. Fired before each iteration of tests starts. There may be more than one
  594. iteration if `GTEST_FLAG(repeat)` is set. `iteration` is the iteration index,
  595. starting from 0.
  596. ##### OnEnvironmentsSetUpStart {#TestEventListener::OnEnvironmentsSetUpStart}
  597. `virtual void TestEventListener::OnEnvironmentsSetUpStart(const UnitTest&
  598. unit_test)`
  599. Fired before environment set-up for each iteration of tests starts.
  600. ##### OnEnvironmentsSetUpEnd {#TestEventListener::OnEnvironmentsSetUpEnd}
  601. `virtual void TestEventListener::OnEnvironmentsSetUpEnd(const UnitTest&
  602. unit_test)`
  603. Fired after environment set-up for each iteration of tests ends.
  604. ##### OnTestSuiteStart {#TestEventListener::OnTestSuiteStart}
  605. `virtual void TestEventListener::OnTestSuiteStart(const TestSuite& test_suite)`
  606. Fired before the test suite starts.
  607. ##### OnTestStart {#TestEventListener::OnTestStart}
  608. `virtual void TestEventListener::OnTestStart(const TestInfo& test_info)`
  609. Fired before the test starts.
  610. ##### OnTestPartResult {#TestEventListener::OnTestPartResult}
  611. `virtual void TestEventListener::OnTestPartResult(const TestPartResult&
  612. test_part_result)`
  613. Fired after a failed assertion or a `SUCCEED()` invocation. If you want to throw
  614. an exception from this function to skip to the next test, it must be an
  615. [`AssertionException`](#AssertionException) or inherited from it.
  616. ##### OnTestEnd {#TestEventListener::OnTestEnd}
  617. `virtual void TestEventListener::OnTestEnd(const TestInfo& test_info)`
  618. Fired after the test ends.
  619. ##### OnTestSuiteEnd {#TestEventListener::OnTestSuiteEnd}
  620. `virtual void TestEventListener::OnTestSuiteEnd(const TestSuite& test_suite)`
  621. Fired after the test suite ends.
  622. ##### OnEnvironmentsTearDownStart {#TestEventListener::OnEnvironmentsTearDownStart}
  623. `virtual void TestEventListener::OnEnvironmentsTearDownStart(const UnitTest&
  624. unit_test)`
  625. Fired before environment tear-down for each iteration of tests starts.
  626. ##### OnEnvironmentsTearDownEnd {#TestEventListener::OnEnvironmentsTearDownEnd}
  627. `virtual void TestEventListener::OnEnvironmentsTearDownEnd(const UnitTest&
  628. unit_test)`
  629. Fired after environment tear-down for each iteration of tests ends.
  630. ##### OnTestIterationEnd {#TestEventListener::OnTestIterationEnd}
  631. `virtual void TestEventListener::OnTestIterationEnd(const UnitTest& unit_test,
  632. int iteration)`
  633. Fired after each iteration of tests finishes.
  634. ##### OnTestProgramEnd {#TestEventListener::OnTestProgramEnd}
  635. `virtual void TestEventListener::OnTestProgramEnd(const UnitTest& unit_test)`
  636. Fired after all test activities have ended.
  637. ### TestEventListeners {#TestEventListeners}
  638. `::testing::TestEventListeners`
  639. Lets users add listeners to track events in GoogleTest.
  640. #### Public Methods {#TestEventListeners-public}
  641. ##### Append {#TestEventListeners::Append}
  642. `void TestEventListeners::Append(TestEventListener* listener)`
  643. Appends an event listener to the end of the list. GoogleTest assumes ownership
  644. of the listener (i.e. it will delete the listener when the test program
  645. finishes).
  646. ##### Release {#TestEventListeners::Release}
  647. `TestEventListener* TestEventListeners::Release(TestEventListener* listener)`
  648. Removes the given event listener from the list and returns it. It then becomes
  649. the caller's responsibility to delete the listener. Returns `NULL` if the
  650. listener is not found in the list.
  651. ##### default_result_printer {#TestEventListeners::default_result_printer}
  652. `TestEventListener* TestEventListeners::default_result_printer() const`
  653. Returns the standard listener responsible for the default console output. Can be
  654. removed from the listeners list to shut down default console output. Note that
  655. removing this object from the listener list with
  656. [`Release()`](#TestEventListeners::Release) transfers its ownership to the
  657. caller and makes this function return `NULL` the next time.
  658. ##### default_xml_generator {#TestEventListeners::default_xml_generator}
  659. `TestEventListener* TestEventListeners::default_xml_generator() const`
  660. Returns the standard listener responsible for the default XML output controlled
  661. by the `--gtest_output=xml` flag. Can be removed from the listeners list by
  662. users who want to shut down the default XML output controlled by this flag and
  663. substitute it with custom one. Note that removing this object from the listener
  664. list with [`Release()`](#TestEventListeners::Release) transfers its ownership to
  665. the caller and makes this function return `NULL` the next time.
  666. ### TestPartResult {#TestPartResult}
  667. `::testing::TestPartResult`
  668. A copyable object representing the result of a test part (i.e. an assertion or
  669. an explicit `FAIL()`, `ADD_FAILURE()`, or `SUCCESS()`).
  670. #### Public Methods {#TestPartResult-public}
  671. ##### type {#TestPartResult::type}
  672. `Type TestPartResult::type() const`
  673. Gets the outcome of the test part.
  674. The return type `Type` is an enum defined as follows:
  675. ```cpp
  676. enum Type {
  677. kSuccess, // Succeeded.
  678. kNonFatalFailure, // Failed but the test can continue.
  679. kFatalFailure, // Failed and the test should be terminated.
  680. kSkip // Skipped.
  681. };
  682. ```
  683. ##### file_name {#TestPartResult::file_name}
  684. `const char* TestPartResult::file_name() const`
  685. Gets the name of the source file where the test part took place, or `NULL` if
  686. it's unknown.
  687. ##### line_number {#TestPartResult::line_number}
  688. `int TestPartResult::line_number() const`
  689. Gets the line in the source file where the test part took place, or `-1` if it's
  690. unknown.
  691. ##### summary {#TestPartResult::summary}
  692. `const char* TestPartResult::summary() const`
  693. Gets the summary of the failure message.
  694. ##### message {#TestPartResult::message}
  695. `const char* TestPartResult::message() const`
  696. Gets the message associated with the test part.
  697. ##### skipped {#TestPartResult::skipped}
  698. `bool TestPartResult::skipped() const`
  699. Returns true if and only if the test part was skipped.
  700. ##### passed {#TestPartResult::passed}
  701. `bool TestPartResult::passed() const`
  702. Returns true if and only if the test part passed.
  703. ##### nonfatally_failed {#TestPartResult::nonfatally_failed}
  704. `bool TestPartResult::nonfatally_failed() const`
  705. Returns true if and only if the test part non-fatally failed.
  706. ##### fatally_failed {#TestPartResult::fatally_failed}
  707. `bool TestPartResult::fatally_failed() const`
  708. Returns true if and only if the test part fatally failed.
  709. ##### failed {#TestPartResult::failed}
  710. `bool TestPartResult::failed() const`
  711. Returns true if and only if the test part failed.
  712. ### TestProperty {#TestProperty}
  713. `::testing::TestProperty`
  714. A copyable object representing a user-specified test property which can be
  715. output as a key/value string pair.
  716. #### Public Methods {#TestProperty-public}
  717. ##### key {#key}
  718. `const char* key() const`
  719. Gets the user-supplied key.
  720. ##### value {#value}
  721. `const char* value() const`
  722. Gets the user-supplied value.
  723. ##### SetValue {#SetValue}
  724. `void SetValue(const std::string& new_value)`
  725. Sets a new value, overriding the previous one.
  726. ### TestResult {#TestResult}
  727. `::testing::TestResult`
  728. Contains information about the result of a single test.
  729. `TestResult` is not copyable.
  730. #### Public Methods {#TestResult-public}
  731. ##### total_part_count {#TestResult::total_part_count}
  732. `int TestResult::total_part_count() const`
  733. Gets the number of all test parts. This is the sum of the number of successful
  734. test parts and the number of failed test parts.
  735. ##### test_property_count {#TestResult::test_property_count}
  736. `int TestResult::test_property_count() const`
  737. Returns the number of test properties.
  738. ##### Passed {#TestResult::Passed}
  739. `bool TestResult::Passed() const`
  740. Returns true if and only if the test passed (i.e. no test part failed).
  741. ##### Skipped {#TestResult::Skipped}
  742. `bool TestResult::Skipped() const`
  743. Returns true if and only if the test was skipped.
  744. ##### Failed {#TestResult::Failed}
  745. `bool TestResult::Failed() const`
  746. Returns true if and only if the test failed.
  747. ##### HasFatalFailure {#TestResult::HasFatalFailure}
  748. `bool TestResult::HasFatalFailure() const`
  749. Returns true if and only if the test fatally failed.
  750. ##### HasNonfatalFailure {#TestResult::HasNonfatalFailure}
  751. `bool TestResult::HasNonfatalFailure() const`
  752. Returns true if and only if the test has a non-fatal failure.
  753. ##### elapsed_time {#TestResult::elapsed_time}
  754. `TimeInMillis TestResult::elapsed_time() const`
  755. Returns the elapsed time, in milliseconds.
  756. ##### start_timestamp {#TestResult::start_timestamp}
  757. `TimeInMillis TestResult::start_timestamp() const`
  758. Gets the time of the test case start, in ms from the start of the UNIX epoch.
  759. ##### GetTestPartResult {#TestResult::GetTestPartResult}
  760. `const TestPartResult& TestResult::GetTestPartResult(int i) const`
  761. Returns the [`TestPartResult`](#TestPartResult) for the `i`-th test part result
  762. among all the results. `i` can range from 0 to `total_part_count() - 1`. If `i`
  763. is not in that range, aborts the program.
  764. ##### GetTestProperty {#TestResult::GetTestProperty}
  765. `const TestProperty& TestResult::GetTestProperty(int i) const`
  766. Returns the [`TestProperty`](#TestProperty) object for the `i`-th test property.
  767. `i` can range from 0 to `test_property_count() - 1`. If `i` is not in that
  768. range, aborts the program.
  769. ### TimeInMillis {#TimeInMillis}
  770. `::testing::TimeInMillis`
  771. An integer type representing time in milliseconds.
  772. ### Types {#Types}
  773. `::testing::Types<T...>`
  774. Represents a list of types for use in typed tests and type-parameterized tests.
  775. The template argument `T...` can be any number of types, for example:
  776. ```
  777. ::testing::Types<char, int, unsigned int>
  778. ```
  779. See [Typed Tests](../advanced.md#typed-tests) and
  780. [Type-Parameterized Tests](../advanced.md#type-parameterized-tests) for more
  781. information.
  782. ### WithParamInterface {#WithParamInterface}
  783. `::testing::WithParamInterface<T>`
  784. The pure interface class that all value-parameterized tests inherit from.
  785. A value-parameterized test fixture class must inherit from both [`Test`](#Test)
  786. and `WithParamInterface`. In most cases that just means inheriting from
  787. [`TestWithParam`](#TestWithParam), but more complicated test hierarchies may
  788. need to inherit from `Test` and `WithParamInterface` at different levels.
  789. This interface defines the type alias `ParamType` for the parameter type `T` and
  790. has support for accessing the test parameter value via the `GetParam()` method:
  791. ```
  792. static const ParamType& GetParam()
  793. ```
  794. For more information, see
  795. [Value-Parameterized Tests](../advanced.md#value-parameterized-tests).
  796. ## Functions
  797. GoogleTest defines the following functions to help with writing and running
  798. tests.
  799. ### InitGoogleTest {#InitGoogleTest}
  800. `void ::testing::InitGoogleTest(int* argc, char** argv)` \
  801. `void ::testing::InitGoogleTest(int* argc, wchar_t** argv)` \
  802. `void ::testing::InitGoogleTest()`
  803. Initializes GoogleTest. This must be called before calling
  804. [`RUN_ALL_TESTS()`](#RUN_ALL_TESTS). In particular, it parses the command line
  805. for the flags that GoogleTest recognizes. Whenever a GoogleTest flag is seen, it
  806. is removed from `argv`, and `*argc` is decremented.
  807. No value is returned. Instead, the GoogleTest flag variables are updated.
  808. The `InitGoogleTest(int* argc, wchar_t** argv)` overload can be used in Windows
  809. programs compiled in `UNICODE` mode.
  810. The argument-less `InitGoogleTest()` overload can be used on Arduino/embedded
  811. platforms where there is no `argc`/`argv`.
  812. ### AddGlobalTestEnvironment {#AddGlobalTestEnvironment}
  813. `Environment* ::testing::AddGlobalTestEnvironment(Environment* env)`
  814. Adds a test environment to the test program. Must be called before
  815. [`RUN_ALL_TESTS()`](#RUN_ALL_TESTS) is called. See
  816. [Global Set-Up and Tear-Down](../advanced.md#global-set-up-and-tear-down) for
  817. more information.
  818. See also [`Environment`](#Environment).
  819. ### RegisterTest {#RegisterTest}
  820. ```cpp
  821. template <typename Factory>
  822. TestInfo* ::testing::RegisterTest(const char* test_suite_name, const char* test_name,
  823. const char* type_param, const char* value_param,
  824. const char* file, int line, Factory factory)
  825. ```
  826. Dynamically registers a test with the framework.
  827. The `factory` argument is a factory callable (move-constructible) object or
  828. function pointer that creates a new instance of the `Test` object. It handles
  829. ownership to the caller. The signature of the callable is `Fixture*()`, where
  830. `Fixture` is the test fixture class for the test. All tests registered with the
  831. same `test_suite_name` must return the same fixture type. This is checked at
  832. runtime.
  833. The framework will infer the fixture class from the factory and will call the
  834. `SetUpTestSuite` and `TearDownTestSuite` methods for it.
  835. Must be called before [`RUN_ALL_TESTS()`](#RUN_ALL_TESTS) is invoked, otherwise
  836. behavior is undefined.
  837. See
  838. [Registering tests programmatically](../advanced.md#registering-tests-programmatically)
  839. for more information.
  840. ### RUN_ALL_TESTS {#RUN_ALL_TESTS}
  841. `int RUN_ALL_TESTS()`
  842. Use this function in `main()` to run all tests. It returns `0` if all tests are
  843. successful, or `1` otherwise.
  844. `RUN_ALL_TESTS()` should be invoked after the command line has been parsed by
  845. [`InitGoogleTest()`](#InitGoogleTest).
  846. This function was formerly a macro; thus, it is in the global namespace and has
  847. an all-caps name.
  848. ### AssertionSuccess {#AssertionSuccess}
  849. `AssertionResult ::testing::AssertionSuccess()`
  850. Creates a successful assertion result. See
  851. [`AssertionResult`](#AssertionResult).
  852. ### AssertionFailure {#AssertionFailure}
  853. `AssertionResult ::testing::AssertionFailure()`
  854. Creates a failed assertion result. Use the `<<` operator to store a failure
  855. message:
  856. ```cpp
  857. ::testing::AssertionFailure() << "My failure message";
  858. ```
  859. See [`AssertionResult`](#AssertionResult).
  860. ### StaticAssertTypeEq {#StaticAssertTypeEq}
  861. `::testing::StaticAssertTypeEq<T1, T2>()`
  862. Compile-time assertion for type equality. Compiles if and only if `T1` and `T2`
  863. are the same type. The value it returns is irrelevant.
  864. See [Type Assertions](../advanced.md#type-assertions) for more information.
  865. ### PrintToString {#PrintToString}
  866. `std::string ::testing::PrintToString(x)`
  867. Prints any value `x` using GoogleTest's value printer.
  868. See
  869. [Teaching GoogleTest How to Print Your Values](../advanced.md#teaching-googletest-how-to-print-your-values)
  870. for more information.
  871. ### PrintToStringParamName {#PrintToStringParamName}
  872. `std::string ::testing::PrintToStringParamName(TestParamInfo<T>& info)`
  873. A built-in parameterized test name generator which returns the result of
  874. [`PrintToString`](#PrintToString) called on `info.param`. Does not work when the
  875. test parameter is a `std::string` or C string. See
  876. [Specifying Names for Value-Parameterized Test Parameters](../advanced.md#specifying-names-for-value-parameterized-test-parameters)
  877. for more information.
  878. See also [`TestParamInfo`](#TestParamInfo) and
  879. [`INSTANTIATE_TEST_SUITE_P`](#INSTANTIATE_TEST_SUITE_P).