Lines Matching full:test

5 This page lists the facilities provided by GoogleTest for writing test programs.
12 ### TEST {#TEST}
15 TEST(<em>TestSuiteName</em>, <em>TestName</em>) {
20 Defines an individual test named *`TestName`* in the test suite
24 and must not contain underscores (`_`). Tests in different test suites can have
27 The statements within the test body can be any code under test.
28 [Assertions](assertions.md) used within the test body determine the outcome of
29 the test.
39 Defines an individual test named *`TestName`* that uses the test fixture class
40 *`TestFixtureName`*. The test suite name is *`TestFixtureName`*.
44 the name of a test fixture class—see
45 [Test Fixtures](../primer.md#same-data-multiple-tests).
47 The statements within the test body can be any code under test.
48 [Assertions](assertions.md) used within the test body determine the outcome of
49 the test.
59 Defines an individual value-parameterized test named *`TestName`* that uses the
60 test fixture class *`TestFixtureName`*. The test suite name is
65 the name of a value-parameterized test fixture class—see
68 The statements within the test body can be any code under test. Within the test
69 body, the test parameter can be accessed with the `GetParam()` function (see
80 [Assertions](assertions.md) used within the test body determine the outcome of
81 the test.
91 Instantiates the value-parameterized test suite *`TestSuiteName`* (defined with
95 test suite, to distinguish between multiple instantiations. In test output, the
96 instantiation name is added as a prefix to the test suite name
101 functions that generate the test parameters, all defined in the `::testing`
116 generates custom test name suffixes based on the test parameters. The function
119 The test name suffix can only contain alphanumeric characters and underscores.
128 // Can use info.param here to generate the test suffix
145 Defines a typed test suite based on the test fixture *`TestFixtureName`*. The
146 test suite name is *`TestFixtureName`*.
153 class MyFixture : public testing::Test {
200 Defines an individual typed test named *`TestName`* in the typed test suite
201 *`TestSuiteName`*. The test suite must be defined with
204 Within the test body, the special name `TypeParam` refers to the type parameter,
209 // Inside a test, refer to the special name TypeParam to get the type
233 Defines a type-parameterized test suite based on the test fixture
234 *`TestFixtureName`*. The test suite name is *`TestFixtureName`*.
251 Defines an individual type-parameterized test named *`TestName`* in the
252 type-parameterized test suite *`TestSuiteName`*. The test suite must be defined
255 Within the test body, the special name `TypeParam` refers to the type parameter,
267 Registers the type-parameterized tests *`TestNames...`* of the test suite
268 *`TestSuiteName`*. The test suite and tests must be defined with
274 // Define the test suite and tests.
279 // Register the tests in the test suite.
291 Instantiates the type-parameterized test suite *`TestSuiteName`*. The test suite
296 test suite, to distinguish between multiple instantiations. In test output, the
297 instantiation name is added as a prefix to the test suite name
319 Within a class body, declares an individual test as a friend of the class,
320 enabling the test to access private class members.
323 class, test fixtures and tests must be defined in the exact same namespace,
341 Then the test code should look like:
346 class MyClassTest : public testing::Test {
376 Prevents further test execution at runtime.
378 Can be used in individual test cases or in the `SetUp()` methods of test
379 environments or test fixtures (classes derived from the
380 [`Environment`](#Environment) or [`Test`](#Test) classes). If used in a global
381 test environment `SetUp()` method, it skips all tests in the test program. If
382 used in a test fixture `SetUp()` method, it skips all tests in the corresponding
383 test suite.
387 See [Skipping Test Execution](../advanced.md#skipping-test-execution) for more
394 Allows the value-parameterized test suite *`TestSuiteName`* to be
399 test in the test suite `GoogleTestVerification`.
401 given test suite.
440 Represents a global test environment. See
461 An instance of this class causes a trace to be included in every test failure
484 ### Test {#Test}
486 `testing::Test`
488 The abstract class that all tests inherit from. `Test` is not copyable.
490 #### Public Methods {#Test-public} argument
492 ##### SetUpTestSuite {#Test::SetUpTestSuite}
494 `static void Test::SetUpTestSuite()`
496 Performs shared setup for all tests in the test suite. GoogleTest calls
497 `SetUpTestSuite()` before running the first test in the test suite.
499 ##### TearDownTestSuite {#Test::TearDownTestSuite}
501 `static void Test::TearDownTestSuite()`
503 Performs shared teardown for all tests in the test suite. GoogleTest calls
504 `TearDownTestSuite()` after running the last test in the test suite.
506 ##### HasFatalFailure {#Test::HasFatalFailure}
508 `static bool Test::HasFatalFailure()`
510 Returns true if and only if the current test has a fatal failure.
512 ##### HasNonfatalFailure {#Test::HasNonfatalFailure}
514 `static bool Test::HasNonfatalFailure()`
516 Returns true if and only if the current test has a nonfatal failure.
518 ##### HasFailure {#Test::HasFailure}
520 `static bool Test::HasFailure()`
522 Returns true if and only if the current test has any failure, either fatal or
525 ##### IsSkipped {#Test::IsSkipped}
527 `static bool Test::IsSkipped()`
529 Returns true if and only if the current test was skipped.
531 ##### RecordProperty {#Test::RecordProperty}
533 `static void Test::RecordProperty(const std::string& key, const std::string&
535 `static void Test::RecordProperty(const std::string& key, int value)`
537 Logs a property for the current test, test suite, or entire invocation of the
538 test program. Only the last value for a given key is logged.
545 that are not members of the test fixture.
547 Calls to `RecordProperty` made during the lifespan of the test (from the moment
556 #### Protected Methods {#Test-protected} argument
558 ##### SetUp {#Test::SetUp}
560 `virtual void Test::SetUp()`
562 Override this to perform test fixture setup. GoogleTest calls `SetUp()` before
563 running each individual test.
565 ##### TearDown {#Test::TearDown}
567 `virtual void Test::TearDown()`
569 Override this to perform test fixture teardown. GoogleTest calls `TearDown()`
570 after running each individual test.
576 A convenience class which inherits from both [`Test`](#Test) and
581 Represents a test suite. `TestSuite` is not copyable.
589 Gets the name of the test suite.
596 type-parameterized test suite. See [Typed Tests](../advanced.md#typed-tests) and
603 Returns true if any test in this test suite should run.
609 Gets the number of successful tests in this test suite.
615 Gets the number of skipped tests in this test suite.
621 Gets the number of failed tests in this test suite.
633 Gets the number of disabled tests in this test suite.
645 Get the number of tests in this test suite that should run.
651 Gets the number of all tests in this test suite.
657 Returns true if and only if the test suite passed.
663 Returns true if and only if the test suite failed.
675 Gets the time of the test suite start, in ms from the start of the UNIX epoch.
681 Returns the [`TestInfo`](#TestInfo) for the `i`-th test among all the tests. `i`
689 Returns the [`TestResult`](#TestResult) that holds test properties recorded
696 Stores information about a test.
704 Returns the test suite name.
710 Returns the test name.
717 type-parameterized test. See [Typed Tests](../advanced.md#typed-tests) and
725 a value-parameterized test. See
732 Returns the file name where this test is defined.
738 Returns the line where this test is defined.
744 Returns true if this test should not be run because it's in another shard.
750 Returns true if this test should run, that is if the test is not disabled (or it
763 Returns true if and only if this test will appear in the XML report.
769 Returns the result of the test. See [`TestResult`](#TestResult).
775 Describes a parameter to a value-parameterized test. The type `T` is the type of
785 This class contains information about the test program.
806 Returns the working directory when the first [`TEST()`](#TEST) or
813 Returns the [`TestSuite`](#TestSuite) object for the test that's currently
814 running, or `NULL` if no test is running.
820 Returns the [`TestInfo`](#TestInfo) object for the test that's currently
821 running, or `NULL` if no test is running.
827 Returns the random seed used at the start of the current test run.
833 Gets the number of successful test suites.
839 Gets the number of failed test suites.
845 Gets the number of all test suites.
851 Gets the number of all test suites that contain at least one test that should
906 Gets the time of the test program start, in ms from the start of the UNIX epoch.
918 Returns true if and only if the unit test passed (i.e. all test suites passed).
924 Returns true if and only if the unit test failed (i.e. some test suite failed or
931 Gets the [`TestSuite`](#TestSuite) object for the `i`-th test suite among all
932 the test suites. `i` can range from 0 to `total_test_suite_count() - 1`. If `i`
939 Returns the [`TestResult`](#TestResult) containing information on test failures
940 and properties logged outside of individual test suites.
962 Fired before any test activity starts.
991 Fired before the test suite starts.
997 Fired before the test starts.
1005 an exception from this function to skip to the next test, it must be an
1012 Fired after the test ends.
1018 Fired after the test suite ends.
1045 Fired after all test activities have ended.
1060 of the listener (i.e. it will delete the listener when the test program
1096 A copyable object representing the result of a test part (i.e. an assertion or
1105 Gets the outcome of the test part.
1112 kNonFatalFailure, // Failed but the test can continue.
1113 kFatalFailure, // Failed and the test should be terminated.
1122 Gets the name of the source file where the test part took place, or `NULL` if
1129 Gets the line in the source file where the test part took place, or `-1` if it's
1142 Gets the message associated with the test part.
1148 Returns true if and only if the test part was skipped.
1154 Returns true if and only if the test part passed.
1160 Returns true if and only if the test part non-fatally failed.
1166 Returns true if and only if the test part fatally failed.
1172 Returns true if and only if the test part failed.
1178 A copyable object representing a user-specified test property which can be
1205 Contains information about the result of a single test.
1215 Gets the number of all test parts. This is the sum of the number of successful
1216 test parts and the number of failed test parts.
1222 Returns the number of test properties.
1228 Returns true if and only if the test passed (i.e. no test part failed).
1234 Returns true if and only if the test was skipped.
1240 Returns true if and only if the test failed.
1246 Returns true if and only if the test fatally failed.
1252 Returns true if and only if the test has a non-fatal failure.
1264 Gets the time of the test case start, in ms from the start of the UNIX epoch.
1270 Returns the [`TestPartResult`](#TestPartResult) for the `i`-th test part result
1278 Returns the [`TestProperty`](#TestProperty) object for the `i`-th test property.
1310 A value-parameterized test fixture class must inherit from both [`Test`](#Test)
1312 [`TestWithParam`](#TestWithParam), but more complicated test hierarchies may
1313 need to inherit from `Test` and `WithParamInterface` at different levels.
1316 has support for accessing the test parameter value via the `GetParam()` method:
1355 Adds a test environment to the test program. Must be called before
1371 Dynamically registers a test with the framework.
1374 function pointer that creates a new instance of the `Test` object. It handles
1376 `Fixture` is the test fixture class for the test. All tests registered with the
1446 A built-in parameterized test name generator which returns the result of
1448 test parameter is a `std::string` or C string. See
1449 …cifying Names for Value-Parameterized Test Parameters](../advanced.md#specifying-names-for-value-p…