Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
testing::internal::UnitTestImpl Class Reference

#include <gtest-internal-inl.h>

Public Types

enum  ReactionToSharding { HONOR_SHARDING_PROTOCOL , IGNORE_SHARDING_PROTOCOL }
 

Public Member Functions

 UnitTestImpl (UnitTest *parent)
 
virtual ~UnitTestImpl ()
 
TestPartResultReporterInterfaceGetGlobalTestPartResultReporter ()
 
void SetGlobalTestPartResultReporter (TestPartResultReporterInterface *reporter)
 
TestPartResultReporterInterfaceGetTestPartResultReporterForCurrentThread ()
 
void SetTestPartResultReporterForCurrentThread (TestPartResultReporterInterface *reporter)
 
int successful_test_case_count () const
 
int failed_test_case_count () const
 
int total_test_case_count () const
 
int test_case_to_run_count () const
 
int successful_test_count () const
 
int failed_test_count () const
 
int reportable_disabled_test_count () const
 
int disabled_test_count () const
 
int reportable_test_count () const
 
int total_test_count () const
 
int test_to_run_count () const
 
TimeInMillis start_timestamp () const
 
TimeInMillis elapsed_time () const
 
bool Passed () const
 
bool Failed () const
 
const TestCaseGetTestCase (int i) const
 
TestCaseGetMutableTestCase (int i)
 
TestEventListenerslisteners ()
 
TestResultcurrent_test_result ()
 
const TestResultad_hoc_test_result () const
 
void set_os_stack_trace_getter (OsStackTraceGetterInterface *getter)
 
OsStackTraceGetterInterfaceos_stack_trace_getter ()
 
std::string CurrentOsStackTraceExceptTop (int skip_count) GTEST_NO_INLINE_
 
TestCaseGetTestCase (const char *test_case_name, const char *type_param, Test::SetUpTestCaseFunc set_up_tc, Test::TearDownTestCaseFunc tear_down_tc)
 
void AddTestInfo (Test::SetUpTestCaseFunc set_up_tc, Test::TearDownTestCaseFunc tear_down_tc, TestInfo *test_info)
 
internal::ParameterizedTestCaseRegistryparameterized_test_registry ()
 
void set_current_test_case (TestCase *a_current_test_case)
 
void set_current_test_info (TestInfo *a_current_test_info)
 
void RegisterParameterizedTests ()
 
bool RunAllTests ()
 
void ClearNonAdHocTestResult ()
 
void ClearAdHocTestResult ()
 
void RecordProperty (const TestProperty &test_property)
 
int FilterTests (ReactionToSharding shard_tests)
 
void ListTestsMatchingFilter ()
 
const TestCasecurrent_test_case () const
 
TestInfocurrent_test_info ()
 
const TestInfocurrent_test_info () const
 
std::vector< Environment * > & environments ()
 
std::vector< TraceInfo > & gtest_trace_stack ()
 
const std::vector< TraceInfo > & gtest_trace_stack () const
 
void ConfigureXmlOutput ()
 
void PostFlagParsingInit ()
 
int random_seed () const
 
internal::Randomrandom ()
 
void ShuffleTests ()
 
void UnshuffleTests ()
 
bool catch_exceptions () const
 

Friends

class ::testing::UnitTest
 

Detailed Description

Definition at line 495 of file gtest-internal-inl.h.

Member Enumeration Documentation

◆ ReactionToSharding

Enumerator
HONOR_SHARDING_PROTOCOL 
IGNORE_SHARDING_PROTOCOL 

Definition at line 711 of file gtest-internal-inl.h.

Constructor & Destructor Documentation

◆ UnitTestImpl()

testing::internal::UnitTestImpl::UnitTestImpl ( UnitTest * parent)
explicit

Definition at line 4730 of file gtest.cc.

4731 : parent_(parent),
4732 GTEST_DISABLE_MSC_WARNINGS_PUSH_(4355 /* using this in initializer */)
4733 default_global_test_part_result_reporter_(this),
4734 default_per_thread_test_part_result_reporter_(this),
4736 global_test_part_result_repoter_(
4737 &default_global_test_part_result_reporter_),
4738 per_thread_test_part_result_reporter_(
4739 &default_per_thread_test_part_result_reporter_),
4740 parameterized_test_registry_(),
4741 parameterized_tests_registered_(false),
4742 last_death_test_case_(-1),
4743 current_test_case_(NULL),
4744 current_test_info_(NULL),
4745 ad_hoc_test_result_(),
4746 os_stack_trace_getter_(NULL),
4747 post_flag_parse_init_performed_(false),
4748 random_seed_(0), // Will be overridden by the flag before first use.
4749 random_(0), // Will be reseeded before first use.
4750 start_timestamp_(0),
4751 elapsed_time_(0),
4752#if GTEST_HAS_DEATH_TEST
4753 death_test_factory_(new DefaultDeathTestFactory),
4754#endif
4755 // Will be overridden by the flag before first use.
4756 catch_exceptions_(false) {
4757 listeners()->SetDefaultResultPrinter(new PrettyUnitTestResultPrinter);
4758}
#define GTEST_DISABLE_MSC_WARNINGS_PUSH_(warnings)
Definition gtest-port.h:324
#define GTEST_DISABLE_MSC_WARNINGS_POP_()
Definition gtest-port.h:325
Here is the call graph for this function:

◆ ~UnitTestImpl()

testing::internal::UnitTestImpl::~UnitTestImpl ( )
virtual

Definition at line 4760 of file gtest.cc.

4760 {
4761 // Deletes every TestCase.
4762 ForEach(test_cases_, internal::Delete<TestCase>);
4763
4764 // Deletes every Environment.
4765 ForEach(environments_, internal::Delete<Environment>);
4766
4767 delete os_stack_trace_getter_;
4768}
void ForEach(const Container &c, Functor functor)
Here is the call graph for this function:

Member Function Documentation

◆ ad_hoc_test_result()

const TestResult * testing::internal::UnitTestImpl::ad_hoc_test_result ( ) const
inline

Definition at line 593 of file gtest-internal-inl.h.

593{ return &ad_hoc_test_result_; }

◆ AddTestInfo()

void testing::internal::UnitTestImpl::AddTestInfo ( Test::SetUpTestCaseFunc set_up_tc,
Test::TearDownTestCaseFunc tear_down_tc,
TestInfo * test_info )
inline

Definition at line 641 of file gtest-internal-inl.h.

643 {
644 // In order to support thread-safe death tests, we need to
645 // remember the original working directory when the test program
646 // was first invoked. We cannot do this in RUN_ALL_TESTS(), as
647 // the user may have changed the current directory before calling
648 // RUN_ALL_TESTS(). Therefore we capture the current directory in
649 // AddTestInfo(), which is called to register a TEST or TEST_F
650 // before main() is reached.
651 if (original_working_dir_.IsEmpty()) {
652 original_working_dir_.Set(FilePath::GetCurrentDir());
653 GTEST_CHECK_(!original_working_dir_.IsEmpty())
654 << "Failed to get the current working directory.";
655 }
656
657 GetTestCase(test_info->test_case_name(),
658 test_info->type_param(),
659 set_up_tc,
660 tear_down_tc)->AddTestInfo(test_info);
661 }
void Set(const FilePath &rhs)
static FilePath GetCurrentDir()
const TestCase * GetTestCase(int i) const
#define GTEST_CHECK_(condition)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ catch_exceptions()

bool testing::internal::UnitTestImpl::catch_exceptions ( ) const
inline

Definition at line 797 of file gtest-internal-inl.h.

797{ return catch_exceptions_; }

◆ ClearAdHocTestResult()

void testing::internal::UnitTestImpl::ClearAdHocTestResult ( )
inline

Definition at line 701 of file gtest-internal-inl.h.

701 {
702 ad_hoc_test_result_.Clear();
703 }

◆ ClearNonAdHocTestResult()

void testing::internal::UnitTestImpl::ClearNonAdHocTestResult ( )
inline

Definition at line 696 of file gtest-internal-inl.h.

696 {
697 ForEach(test_cases_, TestCase::ClearTestCaseResult);
698 }
Here is the caller graph for this function:

◆ ConfigureXmlOutput()

void testing::internal::UnitTestImpl::ConfigureXmlOutput ( )

Definition at line 4803 of file gtest.cc.

4803 {
4804 const std::string& output_format = UnitTestOptions::GetOutputFormat();
4805 if (output_format == "xml") {
4806 listeners()->SetDefaultXmlGenerator(new XmlUnitTestResultPrinter(
4808 } else if (output_format == "json") {
4809 listeners()->SetDefaultXmlGenerator(new JsonUnitTestResultPrinter(
4811 } else if (output_format != "") {
4812 GTEST_LOG_(WARNING) << "WARNING: unrecognized output format \""
4813 << output_format << "\" ignored.";
4814 }
4815}
static std::string GetAbsolutePathToOutputFile()
Definition gtest.cc:438
static std::string GetOutputFormat()
Definition gtest.cc:426
#define GTEST_LOG_(severity)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ current_test_case()

const TestCase * testing::internal::UnitTestImpl::current_test_case ( ) const
inline

Definition at line 727 of file gtest-internal-inl.h.

727{ return current_test_case_; }
Here is the caller graph for this function:

◆ current_test_info() [1/2]

TestInfo * testing::internal::UnitTestImpl::current_test_info ( )
inline

Definition at line 728 of file gtest-internal-inl.h.

728{ return current_test_info_; }
Here is the caller graph for this function:

◆ current_test_info() [2/2]

const TestInfo * testing::internal::UnitTestImpl::current_test_info ( ) const
inline

Definition at line 729 of file gtest-internal-inl.h.

729{ return current_test_info_; }

◆ current_test_result()

TestResult * testing::internal::UnitTestImpl::current_test_result ( )

Definition at line 5345 of file gtest.cc.

5345 {
5346 if (current_test_info_ != NULL) {
5347 return &current_test_info_->result_;
5348 }
5349 if (current_test_case_ != NULL) {
5350 return &current_test_case_->ad_hoc_test_result_;
5351 }
5352 return &ad_hoc_test_result_;
5353}
Here is the caller graph for this function:

◆ CurrentOsStackTraceExceptTop()

std::string testing::internal::UnitTestImpl::CurrentOsStackTraceExceptTop ( int skip_count)

Definition at line 810 of file gtest.cc.

810 {
812 static_cast<int>(GTEST_FLAG(stack_trace_depth)),
813 skip_count + 1
814 // Skips the user-specified number of frames plus this function
815 // itself.
816 ); // NOLINT
817}
virtual std::string CurrentStackTrace(int max_depth, int skip_count)=0
OsStackTraceGetterInterface * os_stack_trace_getter()
Definition gtest.cc:5332
#define GTEST_FLAG(name)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ disabled_test_count()

int testing::internal::UnitTestImpl::disabled_test_count ( ) const

Definition at line 781 of file gtest.cc.

781 {
782 return SumOverTestCaseList(test_cases_, &TestCase::disabled_test_count);
783}
int disabled_test_count() const
Definition gtest.cc:2704
Here is the call graph for this function:

◆ elapsed_time()

TimeInMillis testing::internal::UnitTestImpl::elapsed_time ( ) const
inline

Definition at line 560 of file gtest-internal-inl.h.

560{ return elapsed_time_; }

◆ environments()

std::vector< Environment * > & testing::internal::UnitTestImpl::environments ( )
inline

Definition at line 733 of file gtest-internal-inl.h.

733{ return environments_; }

◆ Failed()

bool testing::internal::UnitTestImpl::Failed ( ) const
inline

Definition at line 567 of file gtest-internal-inl.h.

567 {
569 }
bool Failed() const
Definition gtest.cc:2186
const TestResult * ad_hoc_test_result() const
int failed_test_case_count() const
Definition gtest.cc:749

◆ failed_test_case_count()

int testing::internal::UnitTestImpl::failed_test_case_count ( ) const

Definition at line 749 of file gtest.cc.

749 {
750 return CountIf(test_cases_, TestCaseFailed);
751}
int CountIf(const Container &c, Predicate predicate)
Here is the call graph for this function:

◆ failed_test_count()

int testing::internal::UnitTestImpl::failed_test_count ( ) const

Definition at line 770 of file gtest.cc.

770 {
771 return SumOverTestCaseList(test_cases_, &TestCase::failed_test_count);
772}
int failed_test_count() const
Definition gtest.cc:2694
Here is the call graph for this function:

◆ FilterTests()

int testing::internal::UnitTestImpl::FilterTests ( ReactionToSharding shard_tests)

Definition at line 5202 of file gtest.cc.

5202 {
5203 const Int32 total_shards = shard_tests == HONOR_SHARDING_PROTOCOL ?
5204 Int32FromEnvOrDie(kTestTotalShards, -1) : -1;
5205 const Int32 shard_index = shard_tests == HONOR_SHARDING_PROTOCOL ?
5206 Int32FromEnvOrDie(kTestShardIndex, -1) : -1;
5207
5208 // num_runnable_tests are the number of tests that will
5209 // run across all shards (i.e., match filter and are not disabled).
5210 // num_selected_tests are the number of tests to be run on
5211 // this shard.
5212 int num_runnable_tests = 0;
5213 int num_selected_tests = 0;
5214 for (size_t i = 0; i < test_cases_.size(); i++) {
5215 TestCase* const test_case = test_cases_[i];
5216 const std::string &test_case_name = test_case->name();
5217 test_case->set_should_run(false);
5218
5219 for (size_t j = 0; j < test_case->test_info_list().size(); j++) {
5220 TestInfo* const test_info = test_case->test_info_list()[j];
5221 const std::string test_name(test_info->name());
5222 // A test is disabled if test case name or test name matches
5223 // kDisableTestFilter.
5224 const bool is_disabled =
5226 kDisableTestFilter) ||
5228 kDisableTestFilter);
5229 test_info->is_disabled_ = is_disabled;
5230
5231 const bool matches_filter =
5233 test_name);
5234 test_info->matches_filter_ = matches_filter;
5235
5236 const bool is_runnable =
5237 (GTEST_FLAG(also_run_disabled_tests) || !is_disabled) &&
5238 matches_filter;
5239
5240 const bool is_in_another_shard =
5241 shard_tests != IGNORE_SHARDING_PROTOCOL &&
5242 !ShouldRunTestOnShard(total_shards, shard_index, num_runnable_tests);
5243 test_info->is_in_another_shard_ = is_in_another_shard;
5244 const bool is_selected = is_runnable && !is_in_another_shard;
5245
5246 num_runnable_tests += is_runnable;
5247 num_selected_tests += is_selected;
5248
5249 test_info->should_run_ = is_selected;
5250 test_case->set_should_run(test_case->should_run() || is_selected);
5251 }
5252 }
5253 return num_selected_tests;
5254}
static bool MatchesFilter(const std::string &name, const char *filter)
Definition gtest.cc:496
static bool FilterMatchesTest(const std::string &test_case_name, const std::string &test_name)
Definition gtest.cc:519
GTEST_API_ bool ShouldRunTestOnShard(int total_shards, int shard_index, int test_id)
Definition gtest.cc:5191
TypeWithSize< 4 >::Int Int32
GTEST_API_ Int32 Int32FromEnvOrDie(const char *env_var, Int32 default_val)
Definition gtest.cc:5173
uint16_t j
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetGlobalTestPartResultReporter()

TestPartResultReporterInterface * testing::internal::UnitTestImpl::GetGlobalTestPartResultReporter ( )

Definition at line 719 of file gtest.cc.

719 {
720 internal::MutexLock lock(&global_test_part_result_reporter_mutex_);
721 return global_test_part_result_repoter_;
722}
GTestMutexLock MutexLock
void lock()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetMutableTestCase()

TestCase * testing::internal::UnitTestImpl::GetMutableTestCase ( int i)
inline

Definition at line 580 of file gtest-internal-inl.h.

580 {
581 const int index = GetElementOr(test_case_indices_, i, -1);
582 return index < 0 ? NULL : test_cases_[index];
583 }
E GetElementOr(const std::vector< E > &v, int i, E default_value)
Here is the caller graph for this function:

◆ GetTestCase() [1/2]

TestCase * testing::internal::UnitTestImpl::GetTestCase ( const char * test_case_name,
const char * type_param,
Test::SetUpTestCaseFunc set_up_tc,
Test::TearDownTestCaseFunc tear_down_tc )

Definition at line 4906 of file gtest.cc.

4909 {
4910 // Can we find a TestCase with the given name?
4911 const std::vector<TestCase*>::const_reverse_iterator test_case =
4912 std::find_if(test_cases_.rbegin(), test_cases_.rend(),
4913 TestCaseNameIs(test_case_name));
4914
4915 if (test_case != test_cases_.rend())
4916 return *test_case;
4917
4918 // No. Let's create one.
4919 TestCase* const new_test_case =
4920 new TestCase(test_case_name, type_param, set_up_tc, tear_down_tc);
4921
4922 // Is this a death test case?
4924 kDeathTestCaseFilter)) {
4925 // Yes. Inserts the test case after the last death test case
4926 // defined so far. This only works when the test cases haven't
4927 // been shuffled. Otherwise we may end up running a death test
4928 // after a non-death test.
4929 ++last_death_test_case_;
4930 test_cases_.insert(test_cases_.begin() + last_death_test_case_,
4931 new_test_case);
4932 } else {
4933 // No. Appends to the end of the list.
4934 test_cases_.push_back(new_test_case);
4935 }
4936
4937 test_case_indices_.push_back(static_cast<int>(test_case_indices_.size()));
4938 return new_test_case;
4939}
Here is the call graph for this function:

◆ GetTestCase() [2/2]

const TestCase * testing::internal::UnitTestImpl::GetTestCase ( int i) const
inline

Definition at line 573 of file gtest-internal-inl.h.

573 {
574 const int index = GetElementOr(test_case_indices_, i, -1);
575 return index < 0 ? NULL : test_cases_[i];
576 }

◆ GetTestPartResultReporterForCurrentThread()

TestPartResultReporterInterface * testing::internal::UnitTestImpl::GetTestPartResultReporterForCurrentThread ( )

Definition at line 733 of file gtest.cc.

733 {
734 return per_thread_test_part_result_reporter_.get();
735}

◆ gtest_trace_stack() [1/2]

std::vector< TraceInfo > & testing::internal::UnitTestImpl::gtest_trace_stack ( )
inline

Definition at line 736 of file gtest-internal-inl.h.

736 {
737 return *(gtest_trace_stack_.pointer());
738 }

◆ gtest_trace_stack() [2/2]

const std::vector< TraceInfo > & testing::internal::UnitTestImpl::gtest_trace_stack ( ) const
inline

Definition at line 739 of file gtest-internal-inl.h.

739 {
740 return gtest_trace_stack_.get();
741 }

◆ listeners()

TestEventListeners * testing::internal::UnitTestImpl::listeners ( )
inline

Definition at line 586 of file gtest-internal-inl.h.

586{ return &listeners_; }
Here is the caller graph for this function:

◆ ListTestsMatchingFilter()

void testing::internal::UnitTestImpl::ListTestsMatchingFilter ( )

Definition at line 5279 of file gtest.cc.

5279 {
5280 // Print at most this many characters for each type/value parameter.
5281 const int kMaxParamLength = 250;
5282
5283 for (size_t i = 0; i < test_cases_.size(); i++) {
5284 const TestCase* const test_case = test_cases_[i];
5285 bool printed_test_case_name = false;
5286
5287 for (size_t j = 0; j < test_case->test_info_list().size(); j++) {
5288 const TestInfo* const test_info =
5289 test_case->test_info_list()[j];
5290 if (test_info->matches_filter_) {
5291 if (!printed_test_case_name) {
5292 printed_test_case_name = true;
5293 printf("%s.", test_case->name());
5294 if (test_case->type_param() != NULL) {
5295 printf(" # %s = ", kTypeParamLabel);
5296 // We print the type parameter on a single line to make
5297 // the output easy to parse by a program.
5298 PrintOnOneLine(test_case->type_param(), kMaxParamLength);
5299 }
5300 printf("\n");
5301 }
5302 printf(" %s", test_info->name());
5303 if (test_info->value_param() != NULL) {
5304 printf(" # %s = ", kValueParamLabel);
5305 // We print the value parameter on a single line to make the
5306 // output easy to parse by a program.
5307 PrintOnOneLine(test_info->value_param(), kMaxParamLength);
5308 }
5309 printf("\n");
5310 }
5311 }
5312 }
5313 fflush(stdout);
5314}
LOGGING_API void printf(Category category, const char *format,...)
Definition Logging.cpp:30
Here is the call graph for this function:
Here is the caller graph for this function:

◆ os_stack_trace_getter()

OsStackTraceGetterInterface * testing::internal::UnitTestImpl::os_stack_trace_getter ( )

Definition at line 5332 of file gtest.cc.

5332 {
5333 if (os_stack_trace_getter_ == NULL) {
5334#ifdef GTEST_OS_STACK_TRACE_GETTER_
5335 os_stack_trace_getter_ = new GTEST_OS_STACK_TRACE_GETTER_;
5336#else
5337 os_stack_trace_getter_ = new OsStackTraceGetter;
5338#endif // GTEST_OS_STACK_TRACE_GETTER_
5339 }
5340
5341 return os_stack_trace_getter_;
5342}
Here is the caller graph for this function:

◆ parameterized_test_registry()

internal::ParameterizedTestCaseRegistry & testing::internal::UnitTestImpl::parameterized_test_registry ( )
inline

Definition at line 665 of file gtest-internal-inl.h.

665 {
666 return parameterized_test_registry_;
667 }
Here is the caller graph for this function:

◆ Passed()

bool testing::internal::UnitTestImpl::Passed ( ) const
inline

Definition at line 563 of file gtest-internal-inl.h.

563{ return !Failed(); }
Here is the caller graph for this function:

◆ PostFlagParsingInit()

void testing::internal::UnitTestImpl::PostFlagParsingInit ( )

Definition at line 4840 of file gtest.cc.

4840 {
4841 // Ensures that this function does not execute more than once.
4842 if (!post_flag_parse_init_performed_) {
4843 post_flag_parse_init_performed_ = true;
4844
4845#if defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_)
4846 // Register to send notifications about key process state changes.
4847 listeners()->Append(new GTEST_CUSTOM_TEST_EVENT_LISTENER_());
4848#endif // defined(GTEST_CUSTOM_TEST_EVENT_LISTENER_)
4849
4850#if GTEST_HAS_DEATH_TEST
4851 InitDeathTestSubprocessControlInfo();
4852 SuppressTestEventsIfInSubprocess();
4853#endif // GTEST_HAS_DEATH_TEST
4854
4855 // Registers parameterized tests. This makes parameterized tests
4856 // available to the UnitTest reflection API without running
4857 // RUN_ALL_TESTS.
4859
4860 // Configures listeners for XML output. This makes it possible for users
4861 // to shut down the default XML output before invoking RUN_ALL_TESTS.
4863
4864#if GTEST_CAN_STREAM_RESULTS_
4865 // Configures listeners for streaming test results to the specified server.
4866 ConfigureStreamingOutput();
4867#endif // GTEST_CAN_STREAM_RESULTS_
4868 }
4869}
void Append(TestEventListener *listener)
Definition gtest.cc:4304
Here is the call graph for this function:
Here is the caller graph for this function:

◆ random()

internal::Random * testing::internal::UnitTestImpl::random ( )
inline

Definition at line 786 of file gtest-internal-inl.h.

786{ return &random_; }
Here is the caller graph for this function:

◆ random_seed()

int testing::internal::UnitTestImpl::random_seed ( ) const
inline

Definition at line 783 of file gtest-internal-inl.h.

783{ return random_seed_; }
Here is the caller graph for this function:

◆ RecordProperty()

void testing::internal::UnitTestImpl::RecordProperty ( const TestProperty & test_property)

Definition at line 4775 of file gtest.cc.

4775 {
4776 std::string xml_element;
4777 TestResult* test_result; // TestResult appropriate for property recording.
4778
4779 if (current_test_info_ != NULL) {
4780 xml_element = "testcase";
4781 test_result = &(current_test_info_->result_);
4782 } else if (current_test_case_ != NULL) {
4783 xml_element = "testsuite";
4784 test_result = &(current_test_case_->ad_hoc_test_result_);
4785 } else {
4786 xml_element = "testsuites";
4787 test_result = &ad_hoc_test_result_;
4788 }
4789 test_result->RecordProperty(xml_element, test_property);
4790}

◆ RegisterParameterizedTests()

void testing::internal::UnitTestImpl::RegisterParameterizedTests ( )

Definition at line 2631 of file gtest.cc.

2631 {
2632 if (!parameterized_tests_registered_) {
2633 parameterized_test_registry_.RegisterTests();
2634 parameterized_tests_registered_ = true;
2635 }
2636}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reportable_disabled_test_count()

int testing::internal::UnitTestImpl::reportable_disabled_test_count ( ) const

Definition at line 775 of file gtest.cc.

775 {
776 return SumOverTestCaseList(test_cases_,
778}
int reportable_disabled_test_count() const
Definition gtest.cc:2699
Here is the call graph for this function:

◆ reportable_test_count()

int testing::internal::UnitTestImpl::reportable_test_count ( ) const

Definition at line 786 of file gtest.cc.

786 {
787 return SumOverTestCaseList(test_cases_, &TestCase::reportable_test_count);
788}
int reportable_test_count() const
Definition gtest.cc:2709
Here is the call graph for this function:

◆ RunAllTests()

bool testing::internal::UnitTestImpl::RunAllTests ( )

Definition at line 4955 of file gtest.cc.

4955 {
4956 // True iff Google Test is initialized before RUN_ALL_TESTS() is called.
4957 const bool gtest_is_initialized_before_run_all_tests = GTestIsInitialized();
4958
4959 // Do not run any test if the --help flag was specified.
4960 if (g_help_flag)
4961 return true;
4962
4963 // Repeats the call to the post-flag parsing initialization in case the
4964 // user didn't call InitGoogleTest.
4966
4967 // Even if sharding is not on, test runners may want to use the
4968 // GTEST_SHARD_STATUS_FILE to query whether the test supports the sharding
4969 // protocol.
4971
4972 // True iff we are in a subprocess for running a thread-safe-style
4973 // death test.
4974 bool in_subprocess_for_death_test = false;
4975
4976#if GTEST_HAS_DEATH_TEST
4977 in_subprocess_for_death_test = (internal_run_death_test_flag_.get() != NULL);
4978# if defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)
4979 if (in_subprocess_for_death_test) {
4980 GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_();
4981 }
4982# endif // defined(GTEST_EXTRA_DEATH_TEST_CHILD_SETUP_)
4983#endif // GTEST_HAS_DEATH_TEST
4984
4985 const bool should_shard = ShouldShard(kTestTotalShards, kTestShardIndex,
4986 in_subprocess_for_death_test);
4987
4988 // Compares the full test names with the filter to decide which
4989 // tests to run.
4990 const bool has_tests_to_run = FilterTests(should_shard
4993
4994 // Lists the tests and exits if the --gtest_list_tests flag was specified.
4995 if (GTEST_FLAG(list_tests)) {
4996 // This must be called *after* FilterTests() has been called.
4998 return true;
4999 }
5000
5001 random_seed_ = GTEST_FLAG(shuffle) ?
5002 GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0;
5003
5004 // True iff at least one test has failed.
5005 bool failed = false;
5006
5007 TestEventListener* repeater = listeners()->repeater();
5008
5009 start_timestamp_ = GetTimeInMillis();
5010 repeater->OnTestProgramStart(*parent_);
5011
5012 // How many times to repeat the tests? We don't want to repeat them
5013 // when we are inside the subprocess of a death test.
5014 const int repeat = in_subprocess_for_death_test ? 1 : GTEST_FLAG(repeat);
5015 // Repeats forever if the repeat count is negative.
5016 const bool forever = repeat < 0;
5017 for (int i = 0; forever || i != repeat; i++) {
5018 // We want to preserve failures generated by ad-hoc test
5019 // assertions executed before RUN_ALL_TESTS().
5021
5023
5024 // Shuffles test cases and tests if requested.
5025 if (has_tests_to_run && GTEST_FLAG(shuffle)) {
5026 random()->Reseed(random_seed_);
5027 // This should be done before calling OnTestIterationStart(),
5028 // such that a test event listener can see the actual test order
5029 // in the event.
5030 ShuffleTests();
5031 }
5032
5033 // Tells the unit test event listeners that the tests are about to start.
5034 repeater->OnTestIterationStart(*parent_, i);
5035
5036 // Runs each test case if there is at least one test to run.
5037 if (has_tests_to_run) {
5038 // Sets up all environments beforehand.
5039 repeater->OnEnvironmentsSetUpStart(*parent_);
5040 ForEach(environments_, SetUpEnvironment);
5041 repeater->OnEnvironmentsSetUpEnd(*parent_);
5042
5043 // Runs the tests only if there was no fatal failure during global
5044 // set-up.
5045 if (!Test::HasFatalFailure()) {
5046 for (int test_index = 0; test_index < total_test_case_count();
5047 test_index++) {
5048 GetMutableTestCase(test_index)->Run();
5049 }
5050 }
5051
5052 // Tears down all environments in reverse order afterwards.
5053 repeater->OnEnvironmentsTearDownStart(*parent_);
5054 std::for_each(environments_.rbegin(), environments_.rend(),
5055 TearDownEnvironment);
5056 repeater->OnEnvironmentsTearDownEnd(*parent_);
5057 }
5058
5059 elapsed_time_ = GetTimeInMillis() - start;
5060
5061 // Tells the unit test event listener that the tests have just finished.
5062 repeater->OnTestIterationEnd(*parent_, i);
5063
5064 // Gets the result and clears it.
5065 if (!Passed()) {
5066 failed = true;
5067 }
5068
5069 // Restores the original test order after the iteration. This
5070 // allows the user to quickly repro a failure that happens in the
5071 // N-th iteration without repeating the first (N - 1) iterations.
5072 // This is not enclosed in "if (GTEST_FLAG(shuffle)) { ... }", in
5073 // case the user somehow changes the value of the flag somewhere
5074 // (it's always safe to unshuffle the tests).
5076
5077 if (GTEST_FLAG(shuffle)) {
5078 // Picks a new random seed for each iteration.
5079 random_seed_ = GetNextRandomSeed(random_seed_);
5080 }
5081 }
5082
5083 repeater->OnTestProgramEnd(*parent_);
5084
5085 if (!gtest_is_initialized_before_run_all_tests) {
5086 ColoredPrintf(
5087 COLOR_RED,
5088 "\nIMPORTANT NOTICE - DO NOT IGNORE:\n"
5089 "This test program did NOT call " GTEST_INIT_GOOGLE_TEST_NAME_
5090 "() before calling RUN_ALL_TESTS(). This is INVALID. Soon " GTEST_NAME_
5091 " will start to enforce the valid usage. "
5092 "Please fix it ASAP, or IT WILL START TO FAIL.\n"); // NOLINT
5093#if GTEST_FOR_GOOGLE_
5094 ColoredPrintf(COLOR_RED,
5095 "For more details, see http://wiki/Main/ValidGUnitMain.\n");
5096#endif // GTEST_FOR_GOOGLE_
5097 }
5098
5099 return !failed;
5100}
static bool HasFatalFailure()
Definition gtest.cc:2505
int FilterTests(ReactionToSharding shard_tests)
Definition gtest.cc:5202
int total_test_case_count() const
Definition gtest.cc:754
#define GTEST_NAME_
Definition gtest-port.h:296
#define GTEST_INIT_GOOGLE_TEST_NAME_
Definition gtest-port.h:301
GTEST_API_ bool ShouldShard(const char *total_shards_str, const char *shard_index_str, bool in_subprocess_for_death_test)
Definition gtest.cc:5128
void WriteToShardStatusFileIfNeeded()
Definition gtest.cc:5106
TypeWithSize< 8 >::Int TimeInMillis
int GetNextRandomSeed(int seed)
GTEST_API_ bool g_help_flag
Definition gtest.cc:183
GTEST_API_ TimeInMillis GetTimeInMillis()
Definition gtest.cc:820
int GetRandomSeedFromFlag(Int32 random_seed_flag)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_current_test_case()

void testing::internal::UnitTestImpl::set_current_test_case ( TestCase * a_current_test_case)
inline

Definition at line 670 of file gtest-internal-inl.h.

670 {
671 current_test_case_ = a_current_test_case;
672 }

◆ set_current_test_info()

void testing::internal::UnitTestImpl::set_current_test_info ( TestInfo * a_current_test_info)
inline

Definition at line 677 of file gtest-internal-inl.h.

677 {
678 current_test_info_ = a_current_test_info;
679 }

◆ set_os_stack_trace_getter()

void testing::internal::UnitTestImpl::set_os_stack_trace_getter ( OsStackTraceGetterInterface * getter)

Definition at line 5321 of file gtest.cc.

5322 {
5323 if (os_stack_trace_getter_ != getter) {
5324 delete os_stack_trace_getter_;
5325 os_stack_trace_getter_ = getter;
5326 }
5327}

◆ SetGlobalTestPartResultReporter()

void testing::internal::UnitTestImpl::SetGlobalTestPartResultReporter ( TestPartResultReporterInterface * reporter)

Definition at line 725 of file gtest.cc.

726 {
727 internal::MutexLock lock(&global_test_part_result_reporter_mutex_);
728 global_test_part_result_repoter_ = reporter;
729}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetTestPartResultReporterForCurrentThread()

void testing::internal::UnitTestImpl::SetTestPartResultReporterForCurrentThread ( TestPartResultReporterInterface * reporter)

Definition at line 738 of file gtest.cc.

739 {
740 per_thread_test_part_result_reporter_.set(reporter);
741}
Here is the caller graph for this function:

◆ ShuffleTests()

void testing::internal::UnitTestImpl::ShuffleTests ( )

Definition at line 5357 of file gtest.cc.

5357 {
5358 // Shuffles the death test cases.
5359 ShuffleRange(random(), 0, last_death_test_case_ + 1, &test_case_indices_);
5360
5361 // Shuffles the non-death test cases.
5362 ShuffleRange(random(), last_death_test_case_ + 1,
5363 static_cast<int>(test_cases_.size()), &test_case_indices_);
5364
5365 // Shuffles the tests inside each test case.
5366 for (size_t i = 0; i < test_cases_.size(); i++) {
5367 test_cases_[i]->ShuffleTests(random());
5368 }
5369}
void ShuffleRange(internal::Random *random, int begin, int end, std::vector< E > *v)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ start_timestamp()

TimeInMillis testing::internal::UnitTestImpl::start_timestamp ( ) const
inline

Definition at line 557 of file gtest-internal-inl.h.

557{ return start_timestamp_; }

◆ successful_test_case_count()

int testing::internal::UnitTestImpl::successful_test_case_count ( ) const

Definition at line 744 of file gtest.cc.

744 {
745 return CountIf(test_cases_, TestCasePassed);
746}
Here is the call graph for this function:

◆ successful_test_count()

int testing::internal::UnitTestImpl::successful_test_count ( ) const

Definition at line 765 of file gtest.cc.

765 {
766 return SumOverTestCaseList(test_cases_, &TestCase::successful_test_count);
767}
int successful_test_count() const
Definition gtest.cc:2689
Here is the call graph for this function:

◆ test_case_to_run_count()

int testing::internal::UnitTestImpl::test_case_to_run_count ( ) const

Definition at line 760 of file gtest.cc.

760 {
761 return CountIf(test_cases_, ShouldRunTestCase);
762}
Here is the call graph for this function:

◆ test_to_run_count()

int testing::internal::UnitTestImpl::test_to_run_count ( ) const

Definition at line 796 of file gtest.cc.

796 {
797 return SumOverTestCaseList(test_cases_, &TestCase::test_to_run_count);
798}
int test_to_run_count() const
Definition gtest.cc:2714
Here is the call graph for this function:

◆ total_test_case_count()

int testing::internal::UnitTestImpl::total_test_case_count ( ) const

Definition at line 754 of file gtest.cc.

754 {
755 return static_cast<int>(test_cases_.size());
756}
Here is the caller graph for this function:

◆ total_test_count()

int testing::internal::UnitTestImpl::total_test_count ( ) const

Definition at line 791 of file gtest.cc.

791 {
792 return SumOverTestCaseList(test_cases_, &TestCase::total_test_count);
793}
int total_test_count() const
Definition gtest.cc:2719
Here is the call graph for this function:

◆ UnshuffleTests()

void testing::internal::UnitTestImpl::UnshuffleTests ( )

Definition at line 5372 of file gtest.cc.

5372 {
5373 for (size_t i = 0; i < test_cases_.size(); i++) {
5374 // Unshuffles the tests in each test case.
5375 test_cases_[i]->UnshuffleTests();
5376 // Resets the index of each test case.
5377 test_case_indices_[i] = static_cast<int>(i);
5378 }
5379}
Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ ::testing::UnitTest

friend class ::testing::UnitTest
friend

Definition at line 800 of file gtest-internal-inl.h.


The documentation for this class was generated from the following files: