Finish some missed pieces of the TestCase to TestSuite Migration

PiperOrigin-RevId: 424864779
Change-Id: Iac5cafa3568f5fe41c85c52d28f7d61845f76868
This commit is contained in:
Derek Mauro 2022-01-28 07:26:29 -08:00 committed by Copybara-Service
parent 0b7798b2fb
commit 28e1da21d8
3 changed files with 13 additions and 13 deletions

View File

@ -29,7 +29,7 @@
// This sample shows how to use Google Test listener API to implement
// an alternative console output and how to use the UnitTest reflection API
// to enumerate test cases and tests and to inspect their results.
// to enumerate test suites and tests and to inspect their results.
#include <stdio.h>
@ -38,7 +38,7 @@
using ::testing::EmptyTestEventListener;
using ::testing::InitGoogleTest;
using ::testing::Test;
using ::testing::TestCase;
using ::testing::TestSuite;
using ::testing::TestEventListeners;
using ::testing::TestInfo;
using ::testing::TestPartResult;
@ -61,7 +61,7 @@ class TersePrinter : public EmptyTestEventListener {
void OnTestStart(const TestInfo& test_info) override {
fprintf(stdout,
"*** Test %s.%s starting.\n",
test_info.test_case_name(),
test_info.test_suite_name(),
test_info.name());
fflush(stdout);
}
@ -81,7 +81,7 @@ class TersePrinter : public EmptyTestEventListener {
void OnTestEnd(const TestInfo& test_info) override {
fprintf(stdout,
"*** Test %s.%s ending.\n",
test_info.test_case_name(),
test_info.test_suite_name(),
test_info.name());
fflush(stdout);
}

View File

@ -1148,15 +1148,15 @@ class StreamingListener : public EmptyTestEventListener {
// Note that "event=TestCaseStart" is a wire format and has to remain
// "case" for compatibility
void OnTestCaseStart(const TestCase& test_case) override {
SendLn(std::string("event=TestCaseStart&name=") + test_case.name());
void OnTestSuiteStart(const TestSuite& test_suite) override {
SendLn(std::string("event=TestCaseStart&name=") + test_suite.name());
}
// Note that "event=TestCaseEnd" is a wire format and has to remain
// "case" for compatibility
void OnTestCaseEnd(const TestCase& test_case) override {
SendLn("event=TestCaseEnd&passed=" + FormatBool(test_case.Passed()) +
"&elapsed_time=" + StreamableToString(test_case.elapsed_time()) +
void OnTestSuiteEnd(const TestSuite& test_suite) override {
SendLn("event=TestCaseEnd&passed=" + FormatBool(test_suite.Passed()) +
"&elapsed_time=" + StreamableToString(test_suite.elapsed_time()) +
"ms");
}

View File

@ -111,15 +111,15 @@ TEST_F(StreamingListenerTest, OnTestIterationEnd) {
EXPECT_EQ("event=TestIterationEnd&passed=1&elapsed_time=0ms\n", *output());
}
TEST_F(StreamingListenerTest, OnTestCaseStart) {
TEST_F(StreamingListenerTest, OnTestSuiteStart) {
*output() = "";
streamer_.OnTestCaseStart(TestCase("FooTest", "Bar", nullptr, nullptr));
streamer_.OnTestSuiteStart(TestSuite("FooTest", "Bar", nullptr, nullptr));
EXPECT_EQ("event=TestCaseStart&name=FooTest\n", *output());
}
TEST_F(StreamingListenerTest, OnTestCaseEnd) {
TEST_F(StreamingListenerTest, OnTestSuiteEnd) {
*output() = "";
streamer_.OnTestCaseEnd(TestCase("FooTest", "Bar", nullptr, nullptr));
streamer_.OnTestSuiteEnd(TestSuite("FooTest", "Bar", nullptr, nullptr));
EXPECT_EQ("event=TestCaseEnd&passed=1&elapsed_time=0ms\n", *output());
}