chromeos-dbus-bindings: Print output diff when failing a test.
To help test-driven-development techniques and prevent lazy developers
from copy-pasting the output of the test into the expected results
without inspecting them, this patch shows the unified diff between
the expected result and the generated file.
It is still possible to update the unittest code by appliying the
patch to the *_unittest.cc file.
BUG=None
TEST=Modified an expected result and saw the diff on the unittest.
Change-Id: If24479fed1fa3be67f2a99c092206bf27cf2b110
Reviewed-on: https://chromium-review.googlesource.com/289300
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Trybot-Ready: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
diff --git a/chromeos-dbus-bindings/proxy_generator_mock_unittest.cc b/chromeos-dbus-bindings/proxy_generator_mock_unittest.cc
index aebc973..0f1eb2c 100644
--- a/chromeos-dbus-bindings/proxy_generator_mock_unittest.cc
+++ b/chromeos-dbus-bindings/proxy_generator_mock_unittest.cc
@@ -13,6 +13,7 @@
#include <gtest/gtest.h>
#include "chromeos-dbus-bindings/interface.h"
+#include "chromeos-dbus-bindings/test_utils.h"
using std::string;
using std::vector;
@@ -183,9 +184,7 @@
EXPECT_TRUE(base::ReadFileToString(output_path, &contents));
// The header guards contain the (temporary) filename, so we search for
// the content we need within the string.
- EXPECT_NE(string::npos, contents.find(kExpectedContent))
- << "Expected to find the following content...\n"
- << kExpectedContent << "...within content...\n" << contents;
+ test_utils::EXPECT_TEXT_CONTAINED(kExpectedContent, contents);
}
} // namespace chromeos_dbus_bindings