Finish some missed pieces of the TestCase to TestSuite Migration
PiperOrigin-RevId: 424864779 Change-Id: Iac5cafa3568f5fe41c85c52d28f7d61845f76868
This commit is contained in:
parent
0b7798b2fb
commit
28e1da21d8
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
// This sample shows how to use Google Test listener API to implement
|
// This sample shows how to use Google Test listener API to implement
|
||||||
// an alternative console output and how to use the UnitTest reflection API
|
// 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>
|
#include <stdio.h>
|
||||||
|
|
||||||
@ -38,7 +38,7 @@
|
|||||||
using ::testing::EmptyTestEventListener;
|
using ::testing::EmptyTestEventListener;
|
||||||
using ::testing::InitGoogleTest;
|
using ::testing::InitGoogleTest;
|
||||||
using ::testing::Test;
|
using ::testing::Test;
|
||||||
using ::testing::TestCase;
|
using ::testing::TestSuite;
|
||||||
using ::testing::TestEventListeners;
|
using ::testing::TestEventListeners;
|
||||||
using ::testing::TestInfo;
|
using ::testing::TestInfo;
|
||||||
using ::testing::TestPartResult;
|
using ::testing::TestPartResult;
|
||||||
@ -61,7 +61,7 @@ class TersePrinter : public EmptyTestEventListener {
|
|||||||
void OnTestStart(const TestInfo& test_info) override {
|
void OnTestStart(const TestInfo& test_info) override {
|
||||||
fprintf(stdout,
|
fprintf(stdout,
|
||||||
"*** Test %s.%s starting.\n",
|
"*** Test %s.%s starting.\n",
|
||||||
test_info.test_case_name(),
|
test_info.test_suite_name(),
|
||||||
test_info.name());
|
test_info.name());
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ class TersePrinter : public EmptyTestEventListener {
|
|||||||
void OnTestEnd(const TestInfo& test_info) override {
|
void OnTestEnd(const TestInfo& test_info) override {
|
||||||
fprintf(stdout,
|
fprintf(stdout,
|
||||||
"*** Test %s.%s ending.\n",
|
"*** Test %s.%s ending.\n",
|
||||||
test_info.test_case_name(),
|
test_info.test_suite_name(),
|
||||||
test_info.name());
|
test_info.name());
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
@ -1148,15 +1148,15 @@ class StreamingListener : public EmptyTestEventListener {
|
|||||||
|
|
||||||
// Note that "event=TestCaseStart" is a wire format and has to remain
|
// Note that "event=TestCaseStart" is a wire format and has to remain
|
||||||
// "case" for compatibility
|
// "case" for compatibility
|
||||||
void OnTestCaseStart(const TestCase& test_case) override {
|
void OnTestSuiteStart(const TestSuite& test_suite) override {
|
||||||
SendLn(std::string("event=TestCaseStart&name=") + test_case.name());
|
SendLn(std::string("event=TestCaseStart&name=") + test_suite.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note that "event=TestCaseEnd" is a wire format and has to remain
|
// Note that "event=TestCaseEnd" is a wire format and has to remain
|
||||||
// "case" for compatibility
|
// "case" for compatibility
|
||||||
void OnTestCaseEnd(const TestCase& test_case) override {
|
void OnTestSuiteEnd(const TestSuite& test_suite) override {
|
||||||
SendLn("event=TestCaseEnd&passed=" + FormatBool(test_case.Passed()) +
|
SendLn("event=TestCaseEnd&passed=" + FormatBool(test_suite.Passed()) +
|
||||||
"&elapsed_time=" + StreamableToString(test_case.elapsed_time()) +
|
"&elapsed_time=" + StreamableToString(test_suite.elapsed_time()) +
|
||||||
"ms");
|
"ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,15 +111,15 @@ TEST_F(StreamingListenerTest, OnTestIterationEnd) {
|
|||||||
EXPECT_EQ("event=TestIterationEnd&passed=1&elapsed_time=0ms\n", *output());
|
EXPECT_EQ("event=TestIterationEnd&passed=1&elapsed_time=0ms\n", *output());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(StreamingListenerTest, OnTestCaseStart) {
|
TEST_F(StreamingListenerTest, OnTestSuiteStart) {
|
||||||
*output() = "";
|
*output() = "";
|
||||||
streamer_.OnTestCaseStart(TestCase("FooTest", "Bar", nullptr, nullptr));
|
streamer_.OnTestSuiteStart(TestSuite("FooTest", "Bar", nullptr, nullptr));
|
||||||
EXPECT_EQ("event=TestCaseStart&name=FooTest\n", *output());
|
EXPECT_EQ("event=TestCaseStart&name=FooTest\n", *output());
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(StreamingListenerTest, OnTestCaseEnd) {
|
TEST_F(StreamingListenerTest, OnTestSuiteEnd) {
|
||||||
*output() = "";
|
*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());
|
EXPECT_EQ("event=TestCaseEnd&passed=1&elapsed_time=0ms\n", *output());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user