message: [tf.data] Preparation of using GMock matchers in tensorflow tests.
diff: @@ -23,13 +23,30 @@ limitations under the License.
  #include "tensorflow/core/platform/platform.h"
  #include "tensorflow/core/platform/types.h"
  -// As of September 2016, we continue to attempt to avoid the use of gmock aka
  -// googlemock included in the test framework
  -// (https://github.com/google/googletest) to discourage over-eager use of mocks
  -// that lead to cumbersome class hierarchies and tests that might end up not
  -// testing real code in important ways.
  #include <gtest/gtest.h> // IWYU pragma: export
  +// Includes gmock.h and enables the use of gmock matchers in tensorflow tests.
  +//
  +// Test including this header can use the macros EXPECT_THAT(...) and
  +// ASSERT_THAT(...) in combination with gmock matchers.
  +// Example:
  +// std::vector<int> vec = Foo();
  +// EXPECT_THAT(vec, ::testing::ElementsAre(1,2,3));
  +// EXPECT_THAT(vec, ::testing::UnorderedElementsAre(2,3,1));
  +//
  +// For more details on gmock matchers see:
  +// https://github.com/google/googletest/blob/master/googlemock/docs/CheatSheet.md#matchers
  +//
  +// The advantages of using gmock matchers instead of self defined matchers are
  +// better error messages, more maintainable tests and more test coverage.
  +#if defined(PLATFORM_GOOGLE) || defined(PLATFORM_GOOGLE_ANDROID)
  +#include "testing/base/public/gmock.h"
  +#else
  +#include <gmock/gmock-generated-matchers.h>
  +#include <gmock/gmock-matchers.h>
  +#include <gmock/gmock-more-matchers.h>
  +#endif
  +
  namespace tensorflow {
  namespace testing {
  