1# Testing Reference 2 3<!--* toc_depth: 3 *--> 4 5This page lists the facilities provided by GoogleTest for writing test programs. 6To use them, add `#include <gtest/gtest.h>`. 7 8## Macros 9 10GoogleTest defines the following macros for writing tests. 11 12### TEST {#TEST} 13 14<pre> 15TEST(<em>TestSuiteName</em>, <em>TestName</em>) { 16 ... <em>statements</em> ... 17} 18</pre> 19 20Defines an individual test named *`TestName`* in the test suite 21*`TestSuiteName`*, consisting of the given statements. 22 23Both arguments *`TestSuiteName`* and *`TestName`* must be valid C++ identifiers 24and must not contain underscores (`_`). Tests in different test suites can have 25the same individual name. 26 27The statements within the test body can be any code under test. 28[Assertions](assertions.md) used within the test body determine the outcome of 29the test. 30 31### TEST_F {#TEST_F} 32 33<pre> 34TEST_F(<em>TestFixtureName</em>, <em>TestName</em>) { 35 ... <em>statements</em> ... 36} 37</pre> 38 39Defines an individual test named *`TestName`* that uses the test fixture class 40*`TestFixtureName`*. The test suite name is *`TestFixtureName`*. 41 42Both arguments *`TestFixtureName`* and *`TestName`* must be valid C++ 43identifiers and must not contain underscores (`_`). *`TestFixtureName`* must be 44the name of a test fixture class—see 45[Test Fixtures](../primer.md#same-data-multiple-tests). 46 47The statements within the test body can be any code under test. 48[Assertions](assertions.md) used within the test body determine the outcome of 49the test. 50 51### TEST_P {#TEST_P} 52 53<pre> 54TEST_P(<em>TestFixtureName</em>, <em>TestName</em>) { 55 ... <em>statements</em> ... 56} 57</pre> 58 59Defines an individual value-parameterized test named *`TestName`* that uses the 60test fixture class *`TestFixtureName`*. The test suite name is 61*`TestFixtureName`*. 62 63Both arguments *`TestFixtureName`* and *`TestName`* must be valid C++ 64identifiers and must not contain underscores (`_`). *`TestFixtureName`* must be 65the name of a value-parameterized test fixture class—see 66[Value-Parameterized Tests](../advanced.md#value-parameterized-tests). 67 68The statements within the test body can be any code under test. Within the test 69body, the test parameter can be accessed with the `GetParam()` function (see 70[`WithParamInterface`](#WithParamInterface)). For example: 71 72```cpp 73TEST_P(MyTestSuite, DoesSomething) { 74 ... 75 EXPECT_TRUE(DoSomething(GetParam())); 76 ... 77} 78``` 79 80[Assertions](assertions.md) used within the test body determine the outcome of 81the test. 82 83See also [`INSTANTIATE_TEST_SUITE_P`](#INSTANTIATE_TEST_SUITE_P). 84 85### INSTANTIATE_TEST_SUITE_P {#INSTANTIATE_TEST_SUITE_P} 86 87`INSTANTIATE_TEST_SUITE_P(`*`InstantiationName`*`,`*`TestSuiteName`*`,`*`param_generator`*`)` 88\ 89`INSTANTIATE_TEST_SUITE_P(`*`InstantiationName`*`,`*`TestSuiteName`*`,`*`param_generator`*`,`*`name_generator`*`)` 90 91Instantiates the value-parameterized test suite *`TestSuiteName`* (defined with 92[`TEST_P`](#TEST_P)). 93 94The argument *`InstantiationName`* is a unique name for the instantiation of the 95test suite, to distinguish between multiple instantiations. In test output, the 96instantiation name is added as a prefix to the test suite name 97*`TestSuiteName`*. If *`InstantiationName`* is empty 98(`INSTANTIATE_TEST_SUITE_P(, ...)`), no prefix is added. 99 100The argument *`param_generator`* is one of the following GoogleTest-provided 101functions that generate the test parameters, all defined in the `::testing` 102namespace: 103 104<span id="param-generators"></span> 105 106| Parameter Generator | Behavior | 107| ------------------- | ---------------------------------------------------- | 108| `Range(begin, end [, step])` | Yields values `{begin, begin+step, begin+step+step, ...}`. The values do not include `end`. `step` defaults to 1. | 109| `Values(v1, v2, ..., vN)` | Yields values `{v1, v2, ..., vN}`. | 110| `ValuesIn(container)` or `ValuesIn(begin,end)` | Yields values from a C-style array, an STL-style container, or an iterator range `[begin, end)`. | 111| `Bool()` | Yields sequence `{false, true}`. | 112| `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`. | 113| `ConvertGenerator<T>(g)` | Yields values generated by generator `g`, `static_cast` to `T`. | 114 115The optional last argument *`name_generator`* is a function or functor that 116generates custom test name suffixes based on the test parameters. The function 117must accept an argument of type 118[`TestParamInfo<class ParamType>`](#TestParamInfo) and return a `std::string`. 119The test name suffix can only contain alphanumeric characters and underscores. 120GoogleTest provides [`PrintToStringParamName`](#PrintToStringParamName), or a 121custom function can be used for more control: 122 123```cpp 124INSTANTIATE_TEST_SUITE_P( 125 MyInstantiation, MyTestSuite, 126 testing::Values(...), 127 [](const testing::TestParamInfo<MyTestSuite::ParamType>& info) { 128 // Can use info.param here to generate the test suffix 129 std::string name = ... 130 return name; 131 }); 132``` 133 134For more information, see 135[Value-Parameterized Tests](../advanced.md#value-parameterized-tests). 136 137See also 138[`GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST`](#GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST). 139 140### TYPED_TEST_SUITE {#TYPED_TEST_SUITE} 141 142`TYPED_TEST_SUITE(`*`TestFixtureName`*`,`*`Types`*`)` 143`TYPED_TEST_SUITE(`*`TestFixtureName`*`,`*`Types`*`,`*`NameGenerator`*`)` 144 145Defines a typed test suite based on the test fixture *`TestFixtureName`*. The 146test suite name is *`TestFixtureName`*. 147 148The argument *`TestFixtureName`* is a fixture class template, parameterized by a 149type, for example: 150 151```cpp 152template <typename T> 153class MyFixture : public testing::Test { 154 public: 155 ... 156 using List = std::list<T>; 157 static T shared_; 158 T value_; 159}; 160``` 161 162The argument *`Types`* is a [`Types`](#Types) object representing the list of 163types to run the tests on, for example: 164 165```cpp 166using MyTypes = ::testing::Types<char, int, unsigned int>; 167TYPED_TEST_SUITE(MyFixture, MyTypes); 168``` 169 170The type alias (`using` or `typedef`) is necessary for the `TYPED_TEST_SUITE` 171macro to parse correctly. 172 173The optional third argument *`NameGenerator`* allows specifying a class that 174exposes a templated static function `GetName(int)`. For example: 175 176```cpp 177class NameGenerator { 178 public: 179 template <typename T> 180 static std::string GetName(int) { 181 if constexpr (std::is_same_v<T, char>) return "char"; 182 if constexpr (std::is_same_v<T, int>) return "int"; 183 if constexpr (std::is_same_v<T, unsigned int>) return "unsignedInt"; 184 } 185}; 186TYPED_TEST_SUITE(MyFixture, MyTypes, NameGenerator); 187``` 188 189See also [`TYPED_TEST`](#TYPED_TEST) and 190[Typed Tests](../advanced.md#typed-tests) for more information. 191 192### TYPED_TEST {#TYPED_TEST} 193 194<pre> 195TYPED_TEST(<em>TestSuiteName</em>, <em>TestName</em>) { 196 ... <em>statements</em> ... 197} 198</pre> 199 200Defines an individual typed test named *`TestName`* in the typed test suite 201*`TestSuiteName`*. The test suite must be defined with 202[`TYPED_TEST_SUITE`](#TYPED_TEST_SUITE). 203 204Within the test body, the special name `TypeParam` refers to the type parameter, 205and `TestFixture` refers to the fixture class. See the following example: 206 207```cpp 208TYPED_TEST(MyFixture, Example) { 209 // Inside a test, refer to the special name TypeParam to get the type 210 // parameter. Since we are inside a derived class template, C++ requires 211 // us to visit the members of MyFixture via 'this'. 212 TypeParam n = this->value_; 213 214 // To visit static members of the fixture, add the 'TestFixture::' 215 // prefix. 216 n += TestFixture::shared_; 217 218 // To refer to typedefs in the fixture, add the 'typename TestFixture::' 219 // prefix. The 'typename' is required to satisfy the compiler. 220 typename TestFixture::List values; 221 222 values.push_back(n); 223 ... 224} 225``` 226 227For more information, see [Typed Tests](../advanced.md#typed-tests). 228 229### TYPED_TEST_SUITE_P {#TYPED_TEST_SUITE_P} 230 231`TYPED_TEST_SUITE_P(`*`TestFixtureName`*`)` 232 233Defines a type-parameterized test suite based on the test fixture 234*`TestFixtureName`*. The test suite name is *`TestFixtureName`*. 235 236The argument *`TestFixtureName`* is a fixture class template, parameterized by a 237type. See [`TYPED_TEST_SUITE`](#TYPED_TEST_SUITE) for an example. 238 239See also [`TYPED_TEST_P`](#TYPED_TEST_P) and 240[Type-Parameterized Tests](../advanced.md#type-parameterized-tests) for more 241information. 242 243### TYPED_TEST_P {#TYPED_TEST_P} 244 245<pre> 246TYPED_TEST_P(<em>TestSuiteName</em>, <em>TestName</em>) { 247 ... <em>statements</em> ... 248} 249</pre> 250 251Defines an individual type-parameterized test named *`TestName`* in the 252type-parameterized test suite *`TestSuiteName`*. The test suite must be defined 253with [`TYPED_TEST_SUITE_P`](#TYPED_TEST_SUITE_P). 254 255Within the test body, the special name `TypeParam` refers to the type parameter, 256and `TestFixture` refers to the fixture class. See [`TYPED_TEST`](#TYPED_TEST) 257for an example. 258 259See also [`REGISTER_TYPED_TEST_SUITE_P`](#REGISTER_TYPED_TEST_SUITE_P) and 260[Type-Parameterized Tests](../advanced.md#type-parameterized-tests) for more 261information. 262 263### REGISTER_TYPED_TEST_SUITE_P {#REGISTER_TYPED_TEST_SUITE_P} 264 265`REGISTER_TYPED_TEST_SUITE_P(`*`TestSuiteName`*`,`*`TestNames...`*`)` 266 267Registers the type-parameterized tests *`TestNames...`* of the test suite 268*`TestSuiteName`*. The test suite and tests must be defined with 269[`TYPED_TEST_SUITE_P`](#TYPED_TEST_SUITE_P) and [`TYPED_TEST_P`](#TYPED_TEST_P). 270 271For example: 272 273```cpp 274// Define the test suite and tests. 275TYPED_TEST_SUITE_P(MyFixture); 276TYPED_TEST_P(MyFixture, HasPropertyA) { ... } 277TYPED_TEST_P(MyFixture, HasPropertyB) { ... } 278 279// Register the tests in the test suite. 280REGISTER_TYPED_TEST_SUITE_P(MyFixture, HasPropertyA, HasPropertyB); 281``` 282 283See also [`INSTANTIATE_TYPED_TEST_SUITE_P`](#INSTANTIATE_TYPED_TEST_SUITE_P) and 284[Type-Parameterized Tests](../advanced.md#type-parameterized-tests) for more 285information. 286 287### INSTANTIATE_TYPED_TEST_SUITE_P {#INSTANTIATE_TYPED_TEST_SUITE_P} 288 289`INSTANTIATE_TYPED_TEST_SUITE_P(`*`InstantiationName`*`,`*`TestSuiteName`*`,`*`Types`*`)` 290 291Instantiates the type-parameterized test suite *`TestSuiteName`*. The test suite 292must be registered with 293[`REGISTER_TYPED_TEST_SUITE_P`](#REGISTER_TYPED_TEST_SUITE_P). 294 295The argument *`InstantiationName`* is a unique name for the instantiation of the 296test suite, to distinguish between multiple instantiations. In test output, the 297instantiation name is added as a prefix to the test suite name 298*`TestSuiteName`*. If *`InstantiationName`* is empty 299(`INSTANTIATE_TYPED_TEST_SUITE_P(, ...)`), no prefix is added. 300 301The argument *`Types`* is a [`Types`](#Types) object representing the list of 302types to run the tests on, for example: 303 304```cpp 305using MyTypes = ::testing::Types<char, int, unsigned int>; 306INSTANTIATE_TYPED_TEST_SUITE_P(MyInstantiation, MyFixture, MyTypes); 307``` 308 309The type alias (`using` or `typedef`) is necessary for the 310`INSTANTIATE_TYPED_TEST_SUITE_P` macro to parse correctly. 311 312For more information, see 313[Type-Parameterized Tests](../advanced.md#type-parameterized-tests). 314 315### FRIEND_TEST {#FRIEND_TEST} 316 317`FRIEND_TEST(`*`TestSuiteName`*`,`*`TestName`*`)` 318 319Within a class body, declares an individual test as a friend of the class, 320enabling the test to access private class members. 321 322If the class is defined in a namespace, then in order to be friends of the 323class, test fixtures and tests must be defined in the exact same namespace, 324without inline or anonymous namespaces. 325 326For example, if the class definition looks like the following: 327 328```cpp 329namespace my_namespace { 330 331class MyClass { 332 friend class MyClassTest; 333 FRIEND_TEST(MyClassTest, HasPropertyA); 334 FRIEND_TEST(MyClassTest, HasPropertyB); 335 ... definition of class MyClass ... 336}; 337 338} // namespace my_namespace 339``` 340 341Then the test code should look like: 342 343```cpp 344namespace my_namespace { 345 346class MyClassTest : public testing::Test { 347 ... 348}; 349 350TEST_F(MyClassTest, HasPropertyA) { ... } 351TEST_F(MyClassTest, HasPropertyB) { ... } 352 353} // namespace my_namespace 354``` 355 356See [Testing Private Code](../advanced.md#testing-private-code) for more 357information. 358 359### SCOPED_TRACE {#SCOPED_TRACE} 360 361`SCOPED_TRACE(`*`message`*`)` 362 363Causes the current file name, line number, and the given message *`message`* to 364be added to the failure message for each assertion failure that occurs in the 365scope. 366 367For more information, see 368[Adding Traces to Assertions](../advanced.md#adding-traces-to-assertions). 369 370See also the [`ScopedTrace` class](#ScopedTrace). 371 372### GTEST_SKIP {#GTEST_SKIP} 373 374`GTEST_SKIP()` 375 376Prevents further test execution at runtime. 377 378Can be used in individual test cases or in the `SetUp()` methods of test 379environments or test fixtures (classes derived from the 380[`Environment`](#Environment) or [`Test`](#Test) classes). If used in a global 381test environment `SetUp()` method, it skips all tests in the test program. If 382used in a test fixture `SetUp()` method, it skips all tests in the corresponding 383test suite. 384 385Similar to assertions, `GTEST_SKIP` allows streaming a custom message into it. 386 387See [Skipping Test Execution](../advanced.md#skipping-test-execution) for more 388information. 389 390### GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST {#GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST} 391 392`GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST(`*`TestSuiteName`*`)` 393 394Allows the value-parameterized test suite *`TestSuiteName`* to be 395uninstantiated. 396 397By default, every [`TEST_P`](#TEST_P) call without a corresponding 398[`INSTANTIATE_TEST_SUITE_P`](#INSTANTIATE_TEST_SUITE_P) call causes a failing 399test in the test suite `GoogleTestVerification`. 400`GTEST_ALLOW_UNINSTANTIATED_PARAMETERIZED_TEST` suppresses this failure for the 401given test suite. 402 403## Classes and types 404 405GoogleTest defines the following classes and types to help with writing tests. 406 407### AssertionResult {#AssertionResult} 408 409`testing::AssertionResult` 410 411A class for indicating whether an assertion was successful. 412 413When the assertion wasn't successful, the `AssertionResult` object stores a 414non-empty failure message that can be retrieved with the object's `message()` 415method. 416 417To create an instance of this class, use one of the factory functions 418[`AssertionSuccess()`](#AssertionSuccess) or 419[`AssertionFailure()`](#AssertionFailure). 420 421### AssertionException {#AssertionException} 422 423`testing::AssertionException` 424 425Exception which can be thrown from 426[`TestEventListener::OnTestPartResult`](#TestEventListener::OnTestPartResult). 427 428### EmptyTestEventListener {#EmptyTestEventListener} 429 430`testing::EmptyTestEventListener` 431 432Provides an empty implementation of all methods in the 433[`TestEventListener`](#TestEventListener) interface, such that a subclass only 434needs to override the methods it cares about. 435 436### Environment {#Environment} 437 438`testing::Environment` 439 440Represents a global test environment. See 441[Global Set-Up and Tear-Down](../advanced.md#global-set-up-and-tear-down). 442 443#### Protected Methods {#Environment-protected} 444 445##### SetUp {#Environment::SetUp} 446 447`virtual void Environment::SetUp()` 448 449Override this to define how to set up the environment. 450 451##### TearDown {#Environment::TearDown} 452 453`virtual void Environment::TearDown()` 454 455Override this to define how to tear down the environment. 456 457### ScopedTrace {#ScopedTrace} 458 459`testing::ScopedTrace` 460 461An instance of this class causes a trace to be included in every test failure 462message generated by code in the scope of the lifetime of the `ScopedTrace` 463instance. The effect is undone with the destruction of the instance. 464 465The `ScopedTrace` constructor has the following form: 466 467```cpp 468template <typename T> 469ScopedTrace(const char* file, int line, const T& message) 470``` 471 472Example usage: 473 474```cpp 475testing::ScopedTrace trace("file.cc", 123, "message"); 476``` 477 478The resulting trace includes the given source file path and line number, and the 479given message. The `message` argument can be anything streamable to 480`std::ostream`. 481 482See also [`SCOPED_TRACE`](#SCOPED_TRACE). 483 484### Test {#Test} 485 486`testing::Test` 487 488The abstract class that all tests inherit from. `Test` is not copyable. 489 490#### Public Methods {#Test-public} 491 492##### SetUpTestSuite {#Test::SetUpTestSuite} 493 494`static void Test::SetUpTestSuite()` 495 496Performs shared setup for all tests in the test suite. GoogleTest calls 497`SetUpTestSuite()` before running the first test in the test suite. 498 499##### TearDownTestSuite {#Test::TearDownTestSuite} 500 501`static void Test::TearDownTestSuite()` 502 503Performs shared teardown for all tests in the test suite. GoogleTest calls 504`TearDownTestSuite()` after running the last test in the test suite. 505 506##### HasFatalFailure {#Test::HasFatalFailure} 507 508`static bool Test::HasFatalFailure()` 509 510Returns true if and only if the current test has a fatal failure. 511 512##### HasNonfatalFailure {#Test::HasNonfatalFailure} 513 514`static bool Test::HasNonfatalFailure()` 515 516Returns true if and only if the current test has a nonfatal failure. 517 518##### HasFailure {#Test::HasFailure} 519 520`static bool Test::HasFailure()` 521 522Returns true if and only if the current test has any failure, either fatal or 523nonfatal. 524 525##### IsSkipped {#Test::IsSkipped} 526 527`static bool Test::IsSkipped()` 528 529Returns true if and only if the current test was skipped. 530 531##### RecordProperty {#Test::RecordProperty} 532 533`static void Test::RecordProperty(const std::string& key, const std::string& 534value)` \ 535`static void Test::RecordProperty(const std::string& key, int value)` 536 537Logs a property for the current test, test suite, or entire invocation of the 538test program. Only the last value for a given key is logged. 539 540The key must be a valid XML attribute name, and cannot conflict with the ones 541already used by GoogleTest (`name`, `file`, `line`, `status`, `time`, 542`classname`, `type_param`, and `value_param`). 543 544`RecordProperty` is `public static` so it can be called from utility functions 545that are not members of the test fixture. 546 547Calls to `RecordProperty` made during the lifespan of the test (from the moment 548its constructor starts to the moment its destructor finishes) are output in XML 549as attributes of the `<testcase>` element. Properties recorded from a fixture's 550`SetUpTestSuite` or `TearDownTestSuite` methods are logged as attributes of the 551corresponding `<testsuite>` element. Calls to `RecordProperty` made in the 552global context (before or after invocation of `RUN_ALL_TESTS` or from the 553`SetUp`/`TearDown` methods of registered `Environment` objects) are output as 554attributes of the `<testsuites>` element. 555 556#### Protected Methods {#Test-protected} 557 558##### SetUp {#Test::SetUp} 559 560`virtual void Test::SetUp()` 561 562Override this to perform test fixture setup. GoogleTest calls `SetUp()` before 563running each individual test. 564 565##### TearDown {#Test::TearDown} 566 567`virtual void Test::TearDown()` 568 569Override this to perform test fixture teardown. GoogleTest calls `TearDown()` 570after running each individual test. 571 572### TestWithParam {#TestWithParam} 573 574`testing::TestWithParam<T>` 575 576A convenience class which inherits from both [`Test`](#Test) and 577[`WithParamInterface<T>`](#WithParamInterface). 578 579### TestSuite {#TestSuite} 580 581Represents a test suite. `TestSuite` is not copyable. 582 583#### Public Methods {#TestSuite-public} 584 585##### name {#TestSuite::name} 586 587`const char* TestSuite::name() const` 588 589Gets the name of the test suite. 590 591##### type_param {#TestSuite::type_param} 592 593`const char* TestSuite::type_param() const` 594 595Returns the name of the parameter type, or `NULL` if this is not a typed or 596type-parameterized test suite. See [Typed Tests](../advanced.md#typed-tests) and 597[Type-Parameterized Tests](../advanced.md#type-parameterized-tests). 598 599##### should_run {#TestSuite::should_run} 600 601`bool TestSuite::should_run() const` 602 603Returns true if any test in this test suite should run. 604 605##### successful_test_count {#TestSuite::successful_test_count} 606 607`int TestSuite::successful_test_count() const` 608 609Gets the number of successful tests in this test suite. 610 611##### skipped_test_count {#TestSuite::skipped_test_count} 612 613`int TestSuite::skipped_test_count() const` 614 615Gets the number of skipped tests in this test suite. 616 617##### failed_test_count {#TestSuite::failed_test_count} 618 619`int TestSuite::failed_test_count() const` 620 621Gets the number of failed tests in this test suite. 622 623##### reportable_disabled_test_count {#TestSuite::reportable_disabled_test_count} 624 625`int TestSuite::reportable_disabled_test_count() const` 626 627Gets the number of disabled tests that will be reported in the XML report. 628 629##### disabled_test_count {#TestSuite::disabled_test_count} 630 631`int TestSuite::disabled_test_count() const` 632 633Gets the number of disabled tests in this test suite. 634 635##### reportable_test_count {#TestSuite::reportable_test_count} 636 637`int TestSuite::reportable_test_count() const` 638 639Gets the number of tests to be printed in the XML report. 640 641##### test_to_run_count {#TestSuite::test_to_run_count} 642 643`int TestSuite::test_to_run_count() const` 644 645Get the number of tests in this test suite that should run. 646 647##### total_test_count {#TestSuite::total_test_count} 648 649`int TestSuite::total_test_count() const` 650 651Gets the number of all tests in this test suite. 652 653##### Passed {#TestSuite::Passed} 654 655`bool TestSuite::Passed() const` 656 657Returns true if and only if the test suite passed. 658 659##### Failed {#TestSuite::Failed} 660 661`bool TestSuite::Failed() const` 662 663Returns true if and only if the test suite failed. 664 665##### elapsed_time {#TestSuite::elapsed_time} 666 667`TimeInMillis TestSuite::elapsed_time() const` 668 669Returns the elapsed time, in milliseconds. 670 671##### start_timestamp {#TestSuite::start_timestamp} 672 673`TimeInMillis TestSuite::start_timestamp() const` 674 675Gets the time of the test suite start, in ms from the start of the UNIX epoch. 676 677##### GetTestInfo {#TestSuite::GetTestInfo} 678 679`const TestInfo* TestSuite::GetTestInfo(int i) const` 680 681Returns the [`TestInfo`](#TestInfo) for the `i`-th test among all the tests. `i` 682can range from 0 to `total_test_count() - 1`. If `i` is not in that range, 683returns `NULL`. 684 685##### ad_hoc_test_result {#TestSuite::ad_hoc_test_result} 686 687`const TestResult& TestSuite::ad_hoc_test_result() const` 688 689Returns the [`TestResult`](#TestResult) that holds test properties recorded 690during execution of `SetUpTestSuite` and `TearDownTestSuite`. 691 692### TestInfo {#TestInfo} 693 694`testing::TestInfo` 695 696Stores information about a test. 697 698#### Public Methods {#TestInfo-public} 699 700##### test_suite_name {#TestInfo::test_suite_name} 701 702`const char* TestInfo::test_suite_name() const` 703 704Returns the test suite name. 705 706##### name {#TestInfo::name} 707 708`const char* TestInfo::name() const` 709 710Returns the test name. 711 712##### type_param {#TestInfo::type_param} 713 714`const char* TestInfo::type_param() const` 715 716Returns the name of the parameter type, or `NULL` if this is not a typed or 717type-parameterized test. See [Typed Tests](../advanced.md#typed-tests) and 718[Type-Parameterized Tests](../advanced.md#type-parameterized-tests). 719 720##### value_param {#TestInfo::value_param} 721 722`const char* TestInfo::value_param() const` 723 724Returns the text representation of the value parameter, or `NULL` if this is not 725a value-parameterized test. See 726[Value-Parameterized Tests](../advanced.md#value-parameterized-tests). 727 728##### file {#TestInfo::file} 729 730`const char* TestInfo::file() const` 731 732Returns the file name where this test is defined. 733 734##### line {#TestInfo::line} 735 736`int TestInfo::line() const` 737 738Returns the line where this test is defined. 739 740##### is_in_another_shard {#TestInfo::is_in_another_shard} 741 742`bool TestInfo::is_in_another_shard() const` 743 744Returns true if this test should not be run because it's in another shard. 745 746##### should_run {#TestInfo::should_run} 747 748`bool TestInfo::should_run() const` 749 750Returns true if this test should run, that is if the test is not disabled (or it 751is disabled but the `also_run_disabled_tests` flag has been specified) and its 752full name matches the user-specified filter. 753 754GoogleTest allows the user to filter the tests by their full names. Only the 755tests that match the filter will run. See 756[Running a Subset of the Tests](../advanced.md#running-a-subset-of-the-tests) 757for more information. 758 759##### is_reportable {#TestInfo::is_reportable} 760 761`bool TestInfo::is_reportable() const` 762 763Returns true if and only if this test will appear in the XML report. 764 765##### result {#TestInfo::result} 766 767`const TestResult* TestInfo::result() const` 768 769Returns the result of the test. See [`TestResult`](#TestResult). 770 771### TestParamInfo {#TestParamInfo} 772 773`testing::TestParamInfo<T>` 774 775Describes a parameter to a value-parameterized test. The type `T` is the type of 776the parameter. 777 778Contains the fields `param` and `index` which hold the value of the parameter 779and its integer index respectively. 780 781### UnitTest {#UnitTest} 782 783`testing::UnitTest` 784 785This class contains information about the test program. 786 787`UnitTest` is a singleton class. The only instance is created when 788`UnitTest::GetInstance()` is first called. This instance is never deleted. 789 790`UnitTest` is not copyable. 791 792#### Public Methods {#UnitTest-public} 793 794##### GetInstance {#UnitTest::GetInstance} 795 796`static UnitTest* UnitTest::GetInstance()` 797 798Gets the singleton `UnitTest` object. The first time this method is called, a 799`UnitTest` object is constructed and returned. Consecutive calls will return the 800same object. 801 802##### original_working_dir {#UnitTest::original_working_dir} 803 804`const char* UnitTest::original_working_dir() const` 805 806Returns the working directory when the first [`TEST()`](#TEST) or 807[`TEST_F()`](#TEST_F) was executed. The `UnitTest` object owns the string. 808 809##### current_test_suite {#UnitTest::current_test_suite} 810 811`const TestSuite* UnitTest::current_test_suite() const` 812 813Returns the [`TestSuite`](#TestSuite) object for the test that's currently 814running, or `NULL` if no test is running. 815 816##### current_test_info {#UnitTest::current_test_info} 817 818`const TestInfo* UnitTest::current_test_info() const` 819 820Returns the [`TestInfo`](#TestInfo) object for the test that's currently 821running, or `NULL` if no test is running. 822 823##### random_seed {#UnitTest::random_seed} 824 825`int UnitTest::random_seed() const` 826 827Returns the random seed used at the start of the current test run. 828 829##### successful_test_suite_count {#UnitTest::successful_test_suite_count} 830 831`int UnitTest::successful_test_suite_count() const` 832 833Gets the number of successful test suites. 834 835##### failed_test_suite_count {#UnitTest::failed_test_suite_count} 836 837`int UnitTest::failed_test_suite_count() const` 838 839Gets the number of failed test suites. 840 841##### total_test_suite_count {#UnitTest::total_test_suite_count} 842 843`int UnitTest::total_test_suite_count() const` 844 845Gets the number of all test suites. 846 847##### test_suite_to_run_count {#UnitTest::test_suite_to_run_count} 848 849`int UnitTest::test_suite_to_run_count() const` 850 851Gets the number of all test suites that contain at least one test that should 852run. 853 854##### successful_test_count {#UnitTest::successful_test_count} 855 856`int UnitTest::successful_test_count() const` 857 858Gets the number of successful tests. 859 860##### skipped_test_count {#UnitTest::skipped_test_count} 861 862`int UnitTest::skipped_test_count() const` 863 864Gets the number of skipped tests. 865 866##### failed_test_count {#UnitTest::failed_test_count} 867 868`int UnitTest::failed_test_count() const` 869 870Gets the number of failed tests. 871 872##### reportable_disabled_test_count {#UnitTest::reportable_disabled_test_count} 873 874`int UnitTest::reportable_disabled_test_count() const` 875 876Gets the number of disabled tests that will be reported in the XML report. 877 878##### disabled_test_count {#UnitTest::disabled_test_count} 879 880`int UnitTest::disabled_test_count() const` 881 882Gets the number of disabled tests. 883 884##### reportable_test_count {#UnitTest::reportable_test_count} 885 886`int UnitTest::reportable_test_count() const` 887 888Gets the number of tests to be printed in the XML report. 889 890##### total_test_count {#UnitTest::total_test_count} 891 892`int UnitTest::total_test_count() const` 893 894Gets the number of all tests. 895 896##### test_to_run_count {#UnitTest::test_to_run_count} 897 898`int UnitTest::test_to_run_count() const` 899 900Gets the number of tests that should run. 901 902##### start_timestamp {#UnitTest::start_timestamp} 903 904`TimeInMillis UnitTest::start_timestamp() const` 905 906Gets the time of the test program start, in ms from the start of the UNIX epoch. 907 908##### elapsed_time {#UnitTest::elapsed_time} 909 910`TimeInMillis UnitTest::elapsed_time() const` 911 912Gets the elapsed time, in milliseconds. 913 914##### Passed {#UnitTest::Passed} 915 916`bool UnitTest::Passed() const` 917 918Returns true if and only if the unit test passed (i.e. all test suites passed). 919 920##### Failed {#UnitTest::Failed} 921 922`bool UnitTest::Failed() const` 923 924Returns true if and only if the unit test failed (i.e. some test suite failed or 925something outside of all tests failed). 926 927##### GetTestSuite {#UnitTest::GetTestSuite} 928 929`const TestSuite* UnitTest::GetTestSuite(int i) const` 930 931Gets the [`TestSuite`](#TestSuite) object for the `i`-th test suite among all 932the test suites. `i` can range from 0 to `total_test_suite_count() - 1`. If `i` 933is not in that range, returns `NULL`. 934 935##### ad_hoc_test_result {#UnitTest::ad_hoc_test_result} 936 937`const TestResult& UnitTest::ad_hoc_test_result() const` 938 939Returns the [`TestResult`](#TestResult) containing information on test failures 940and properties logged outside of individual test suites. 941 942##### listeners {#UnitTest::listeners} 943 944`TestEventListeners& UnitTest::listeners()` 945 946Returns the list of event listeners that can be used to track events inside 947GoogleTest. See [`TestEventListeners`](#TestEventListeners). 948 949### TestEventListener {#TestEventListener} 950 951`testing::TestEventListener` 952 953The interface for tracing execution of tests. The methods below are listed in 954the order the corresponding events are fired. 955 956#### Public Methods {#TestEventListener-public} 957 958##### OnTestProgramStart {#TestEventListener::OnTestProgramStart} 959 960`virtual void TestEventListener::OnTestProgramStart(const UnitTest& unit_test)` 961 962Fired before any test activity starts. 963 964##### OnTestIterationStart {#TestEventListener::OnTestIterationStart} 965 966`virtual void TestEventListener::OnTestIterationStart(const UnitTest& unit_test, 967int iteration)` 968 969Fired before each iteration of tests starts. There may be more than one 970iteration if `GTEST_FLAG(repeat)` is set. `iteration` is the iteration index, 971starting from 0. 972 973##### OnEnvironmentsSetUpStart {#TestEventListener::OnEnvironmentsSetUpStart} 974 975`virtual void TestEventListener::OnEnvironmentsSetUpStart(const UnitTest& 976unit_test)` 977 978Fired before environment set-up for each iteration of tests starts. 979 980##### OnEnvironmentsSetUpEnd {#TestEventListener::OnEnvironmentsSetUpEnd} 981 982`virtual void TestEventListener::OnEnvironmentsSetUpEnd(const UnitTest& 983unit_test)` 984 985Fired after environment set-up for each iteration of tests ends. 986 987##### OnTestSuiteStart {#TestEventListener::OnTestSuiteStart} 988 989`virtual void TestEventListener::OnTestSuiteStart(const TestSuite& test_suite)` 990 991Fired before the test suite starts. 992 993##### OnTestStart {#TestEventListener::OnTestStart} 994 995`virtual void TestEventListener::OnTestStart(const TestInfo& test_info)` 996 997Fired before the test starts. 998 999##### OnTestPartResult {#TestEventListener::OnTestPartResult} 1000 1001`virtual void TestEventListener::OnTestPartResult(const TestPartResult& 1002test_part_result)` 1003 1004Fired after a failed assertion or a `SUCCEED()` invocation. If you want to throw 1005an exception from this function to skip to the next test, it must be an 1006[`AssertionException`](#AssertionException) or inherited from it. 1007 1008##### OnTestEnd {#TestEventListener::OnTestEnd} 1009 1010`virtual void TestEventListener::OnTestEnd(const TestInfo& test_info)` 1011 1012Fired after the test ends. 1013 1014##### OnTestSuiteEnd {#TestEventListener::OnTestSuiteEnd} 1015 1016`virtual void TestEventListener::OnTestSuiteEnd(const TestSuite& test_suite)` 1017 1018Fired after the test suite ends. 1019 1020##### OnEnvironmentsTearDownStart {#TestEventListener::OnEnvironmentsTearDownStart} 1021 1022`virtual void TestEventListener::OnEnvironmentsTearDownStart(const UnitTest& 1023unit_test)` 1024 1025Fired before environment tear-down for each iteration of tests starts. 1026 1027##### OnEnvironmentsTearDownEnd {#TestEventListener::OnEnvironmentsTearDownEnd} 1028 1029`virtual void TestEventListener::OnEnvironmentsTearDownEnd(const UnitTest& 1030unit_test)` 1031 1032Fired after environment tear-down for each iteration of tests ends. 1033 1034##### OnTestIterationEnd {#TestEventListener::OnTestIterationEnd} 1035 1036`virtual void TestEventListener::OnTestIterationEnd(const UnitTest& unit_test, 1037int iteration)` 1038 1039Fired after each iteration of tests finishes. 1040 1041##### OnTestProgramEnd {#TestEventListener::OnTestProgramEnd} 1042 1043`virtual void TestEventListener::OnTestProgramEnd(const UnitTest& unit_test)` 1044 1045Fired after all test activities have ended. 1046 1047### TestEventListeners {#TestEventListeners} 1048 1049`testing::TestEventListeners` 1050 1051Lets users add listeners to track events in GoogleTest. 1052 1053#### Public Methods {#TestEventListeners-public} 1054 1055##### Append {#TestEventListeners::Append} 1056 1057`void TestEventListeners::Append(TestEventListener* listener)` 1058 1059Appends an event listener to the end of the list. GoogleTest assumes ownership 1060of the listener (i.e. it will delete the listener when the test program 1061finishes). 1062 1063##### Release {#TestEventListeners::Release} 1064 1065`TestEventListener* TestEventListeners::Release(TestEventListener* listener)` 1066 1067Removes the given event listener from the list and returns it. It then becomes 1068the caller's responsibility to delete the listener. Returns `NULL` if the 1069listener is not found in the list. 1070 1071##### default_result_printer {#TestEventListeners::default_result_printer} 1072 1073`TestEventListener* TestEventListeners::default_result_printer() const` 1074 1075Returns the standard listener responsible for the default console output. Can be 1076removed from the listeners list to shut down default console output. Note that 1077removing this object from the listener list with 1078[`Release()`](#TestEventListeners::Release) transfers its ownership to the 1079caller and makes this function return `NULL` the next time. 1080 1081##### default_xml_generator {#TestEventListeners::default_xml_generator} 1082 1083`TestEventListener* TestEventListeners::default_xml_generator() const` 1084 1085Returns the standard listener responsible for the default XML output controlled 1086by the `--gtest_output=xml` flag. Can be removed from the listeners list by 1087users who want to shut down the default XML output controlled by this flag and 1088substitute it with custom one. Note that removing this object from the listener 1089list with [`Release()`](#TestEventListeners::Release) transfers its ownership to 1090the caller and makes this function return `NULL` the next time. 1091 1092### TestPartResult {#TestPartResult} 1093 1094`testing::TestPartResult` 1095 1096A copyable object representing the result of a test part (i.e. an assertion or 1097an explicit `FAIL()`, `ADD_FAILURE()`, or `SUCCESS()`). 1098 1099#### Public Methods {#TestPartResult-public} 1100 1101##### type {#TestPartResult::type} 1102 1103`Type TestPartResult::type() const` 1104 1105Gets the outcome of the test part. 1106 1107The return type `Type` is an enum defined as follows: 1108 1109```cpp 1110enum Type { 1111 kSuccess, // Succeeded. 1112 kNonFatalFailure, // Failed but the test can continue. 1113 kFatalFailure, // Failed and the test should be terminated. 1114 kSkip // Skipped. 1115}; 1116``` 1117 1118##### file_name {#TestPartResult::file_name} 1119 1120`const char* TestPartResult::file_name() const` 1121 1122Gets the name of the source file where the test part took place, or `NULL` if 1123it's unknown. 1124 1125##### line_number {#TestPartResult::line_number} 1126 1127`int TestPartResult::line_number() const` 1128 1129Gets the line in the source file where the test part took place, or `-1` if it's 1130unknown. 1131 1132##### summary {#TestPartResult::summary} 1133 1134`const char* TestPartResult::summary() const` 1135 1136Gets the summary of the failure message. 1137 1138##### message {#TestPartResult::message} 1139 1140`const char* TestPartResult::message() const` 1141 1142Gets the message associated with the test part. 1143 1144##### skipped {#TestPartResult::skipped} 1145 1146`bool TestPartResult::skipped() const` 1147 1148Returns true if and only if the test part was skipped. 1149 1150##### passed {#TestPartResult::passed} 1151 1152`bool TestPartResult::passed() const` 1153 1154Returns true if and only if the test part passed. 1155 1156##### nonfatally_failed {#TestPartResult::nonfatally_failed} 1157 1158`bool TestPartResult::nonfatally_failed() const` 1159 1160Returns true if and only if the test part non-fatally failed. 1161 1162##### fatally_failed {#TestPartResult::fatally_failed} 1163 1164`bool TestPartResult::fatally_failed() const` 1165 1166Returns true if and only if the test part fatally failed. 1167 1168##### failed {#TestPartResult::failed} 1169 1170`bool TestPartResult::failed() const` 1171 1172Returns true if and only if the test part failed. 1173 1174### TestProperty {#TestProperty} 1175 1176`testing::TestProperty` 1177 1178A copyable object representing a user-specified test property which can be 1179output as a key/value string pair. 1180 1181#### Public Methods {#TestProperty-public} 1182 1183##### key {#key} 1184 1185`const char* key() const` 1186 1187Gets the user-supplied key. 1188 1189##### value {#value} 1190 1191`const char* value() const` 1192 1193Gets the user-supplied value. 1194 1195##### SetValue {#SetValue} 1196 1197`void SetValue(const std::string& new_value)` 1198 1199Sets a new value, overriding the previous one. 1200 1201### TestResult {#TestResult} 1202 1203`testing::TestResult` 1204 1205Contains information about the result of a single test. 1206 1207`TestResult` is not copyable. 1208 1209#### Public Methods {#TestResult-public} 1210 1211##### total_part_count {#TestResult::total_part_count} 1212 1213`int TestResult::total_part_count() const` 1214 1215Gets the number of all test parts. This is the sum of the number of successful 1216test parts and the number of failed test parts. 1217 1218##### test_property_count {#TestResult::test_property_count} 1219 1220`int TestResult::test_property_count() const` 1221 1222Returns the number of test properties. 1223 1224##### Passed {#TestResult::Passed} 1225 1226`bool TestResult::Passed() const` 1227 1228Returns true if and only if the test passed (i.e. no test part failed). 1229 1230##### Skipped {#TestResult::Skipped} 1231 1232`bool TestResult::Skipped() const` 1233 1234Returns true if and only if the test was skipped. 1235 1236##### Failed {#TestResult::Failed} 1237 1238`bool TestResult::Failed() const` 1239 1240Returns true if and only if the test failed. 1241 1242##### HasFatalFailure {#TestResult::HasFatalFailure} 1243 1244`bool TestResult::HasFatalFailure() const` 1245 1246Returns true if and only if the test fatally failed. 1247 1248##### HasNonfatalFailure {#TestResult::HasNonfatalFailure} 1249 1250`bool TestResult::HasNonfatalFailure() const` 1251 1252Returns true if and only if the test has a non-fatal failure. 1253 1254##### elapsed_time {#TestResult::elapsed_time} 1255 1256`TimeInMillis TestResult::elapsed_time() const` 1257 1258Returns the elapsed time, in milliseconds. 1259 1260##### start_timestamp {#TestResult::start_timestamp} 1261 1262`TimeInMillis TestResult::start_timestamp() const` 1263 1264Gets the time of the test case start, in ms from the start of the UNIX epoch. 1265 1266##### GetTestPartResult {#TestResult::GetTestPartResult} 1267 1268`const TestPartResult& TestResult::GetTestPartResult(int i) const` 1269 1270Returns the [`TestPartResult`](#TestPartResult) for the `i`-th test part result 1271among all the results. `i` can range from 0 to `total_part_count() - 1`. If `i` 1272is not in that range, aborts the program. 1273 1274##### GetTestProperty {#TestResult::GetTestProperty} 1275 1276`const TestProperty& TestResult::GetTestProperty(int i) const` 1277 1278Returns the [`TestProperty`](#TestProperty) object for the `i`-th test property. 1279`i` can range from 0 to `test_property_count() - 1`. If `i` is not in that 1280range, aborts the program. 1281 1282### TimeInMillis {#TimeInMillis} 1283 1284`testing::TimeInMillis` 1285 1286An integer type representing time in milliseconds. 1287 1288### Types {#Types} 1289 1290`testing::Types<T...>` 1291 1292Represents a list of types for use in typed tests and type-parameterized tests. 1293 1294The template argument `T...` can be any number of types, for example: 1295 1296``` 1297testing::Types<char, int, unsigned int> 1298``` 1299 1300See [Typed Tests](../advanced.md#typed-tests) and 1301[Type-Parameterized Tests](../advanced.md#type-parameterized-tests) for more 1302information. 1303 1304### WithParamInterface {#WithParamInterface} 1305 1306`testing::WithParamInterface<T>` 1307 1308The pure interface class that all value-parameterized tests inherit from. 1309 1310A value-parameterized test fixture class must inherit from both [`Test`](#Test) 1311and `WithParamInterface`. In most cases that just means inheriting from 1312[`TestWithParam`](#TestWithParam), but more complicated test hierarchies may 1313need to inherit from `Test` and `WithParamInterface` at different levels. 1314 1315This interface defines the type alias `ParamType` for the parameter type `T` and 1316has support for accessing the test parameter value via the `GetParam()` method: 1317 1318``` 1319static const ParamType& GetParam() 1320``` 1321 1322For more information, see 1323[Value-Parameterized Tests](../advanced.md#value-parameterized-tests). 1324 1325## Functions 1326 1327GoogleTest defines the following functions to help with writing and running 1328tests. 1329 1330### InitGoogleTest {#InitGoogleTest} 1331 1332`void testing::InitGoogleTest(int* argc, char** argv)` \ 1333`void testing::InitGoogleTest(int* argc, wchar_t** argv)` \ 1334`void testing::InitGoogleTest()` 1335 1336Initializes GoogleTest. This must be called before calling 1337[`RUN_ALL_TESTS()`](#RUN_ALL_TESTS). In particular, it parses the command line 1338for the flags that GoogleTest recognizes. Whenever a GoogleTest flag is seen, it 1339is removed from `argv`, and `*argc` is decremented. Keep in mind that `argv` 1340must terminate with a `NULL` pointer (i.e. `argv[argc]` is `NULL`), which is 1341already the case with the default `argv` passed to `main`. 1342 1343No value is returned. Instead, the GoogleTest flag variables are updated. 1344 1345The `InitGoogleTest(int* argc, wchar_t** argv)` overload can be used in Windows 1346programs compiled in `UNICODE` mode. 1347 1348The argument-less `InitGoogleTest()` overload can be used on Arduino/embedded 1349platforms where there is no `argc`/`argv`. 1350 1351### AddGlobalTestEnvironment {#AddGlobalTestEnvironment} 1352 1353`Environment* testing::AddGlobalTestEnvironment(Environment* env)` 1354 1355Adds a test environment to the test program. Must be called before 1356[`RUN_ALL_TESTS()`](#RUN_ALL_TESTS) is called. See 1357[Global Set-Up and Tear-Down](../advanced.md#global-set-up-and-tear-down) for 1358more information. 1359 1360See also [`Environment`](#Environment). 1361 1362### RegisterTest {#RegisterTest} 1363 1364```cpp 1365template <typename Factory> 1366TestInfo* testing::RegisterTest(const char* test_suite_name, const char* test_name, 1367 const char* type_param, const char* value_param, 1368 const char* file, int line, Factory factory) 1369``` 1370 1371Dynamically registers a test with the framework. 1372 1373The `factory` argument is a factory callable (move-constructible) object or 1374function pointer that creates a new instance of the `Test` object. It handles 1375ownership to the caller. The signature of the callable is `Fixture*()`, where 1376`Fixture` is the test fixture class for the test. All tests registered with the 1377same `test_suite_name` must return the same fixture type. This is checked at 1378runtime. 1379 1380The framework will infer the fixture class from the factory and will call the 1381`SetUpTestSuite` and `TearDownTestSuite` methods for it. 1382 1383Must be called before [`RUN_ALL_TESTS()`](#RUN_ALL_TESTS) is invoked, otherwise 1384behavior is undefined. 1385 1386See 1387[Registering tests programmatically](../advanced.md#registering-tests-programmatically) 1388for more information. 1389 1390### RUN_ALL_TESTS {#RUN_ALL_TESTS} 1391 1392`int RUN_ALL_TESTS()` 1393 1394Use this function in `main()` to run all tests. It returns `0` if all tests are 1395successful, or `1` otherwise. 1396 1397`RUN_ALL_TESTS()` should be invoked after the command line has been parsed by 1398[`InitGoogleTest()`](#InitGoogleTest). 1399 1400This function was formerly a macro; thus, it is in the global namespace and has 1401an all-caps name. 1402 1403### AssertionSuccess {#AssertionSuccess} 1404 1405`AssertionResult testing::AssertionSuccess()` 1406 1407Creates a successful assertion result. See 1408[`AssertionResult`](#AssertionResult). 1409 1410### AssertionFailure {#AssertionFailure} 1411 1412`AssertionResult testing::AssertionFailure()` 1413 1414Creates a failed assertion result. Use the `<<` operator to store a failure 1415message: 1416 1417```cpp 1418testing::AssertionFailure() << "My failure message"; 1419``` 1420 1421See [`AssertionResult`](#AssertionResult). 1422 1423### StaticAssertTypeEq {#StaticAssertTypeEq} 1424 1425`testing::StaticAssertTypeEq<T1, T2>()` 1426 1427Compile-time assertion for type equality. Compiles if and only if `T1` and `T2` 1428are the same type. The value it returns is irrelevant. 1429 1430See [Type Assertions](../advanced.md#type-assertions) for more information. 1431 1432### PrintToString {#PrintToString} 1433 1434`std::string testing::PrintToString(x)` 1435 1436Prints any value `x` using GoogleTest's value printer. 1437 1438See 1439[Teaching GoogleTest How to Print Your Values](../advanced.md#teaching-googletest-how-to-print-your-values) 1440for more information. 1441 1442### PrintToStringParamName {#PrintToStringParamName} 1443 1444`std::string testing::PrintToStringParamName(TestParamInfo<T>& info)` 1445 1446A built-in parameterized test name generator which returns the result of 1447[`PrintToString`](#PrintToString) called on `info.param`. Does not work when the 1448test parameter is a `std::string` or C string. See 1449[Specifying Names for Value-Parameterized Test Parameters](../advanced.md#specifying-names-for-value-parameterized-test-parameters) 1450for more information. 1451 1452See also [`TestParamInfo`](#TestParamInfo) and 1453[`INSTANTIATE_TEST_SUITE_P`](#INSTANTIATE_TEST_SUITE_P). 1454