Application developers may want to test their code with simulated responses, including errors from a bigtable::Table. To do so, construct a bigtable::Table with an instance of this class. Then use the Google Test framework functions to program the behavior of this mock.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["\u003cp\u003eThis document outlines the \u003ccode\u003eMockDataConnection\u003c/code\u003e class, which is designed to simulate the behavior of \u003ccode\u003egoogle::cloud::bigtable::DataConnection\u003c/code\u003e for testing purposes.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eMockDataConnection\u003c/code\u003e class facilitates testing by allowing developers to mock responses and errors from \u003ccode\u003ebigtable::Table\u003c/code\u003e using the Google Test framework and \u003ccode\u003eMOCK_METHOD()\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe document details the various functions of \u003ccode\u003eMockDataConnection\u003c/code\u003e, such as \u003ccode\u003eApply\u003c/code\u003e, \u003ccode\u003eBulkApply\u003c/code\u003e, \u003ccode\u003eReadRows\u003c/code\u003e, \u003ccode\u003eReadRow\u003c/code\u003e, and others, which can be used to program mock behaviors.\u003c/p\u003e\n"],["\u003cp\u003eThe latest version available is \u003ccode\u003e2.37.0-rc\u003c/code\u003e, and there are several previous versions available, all the way down to \u003ccode\u003e2.11.0\u003c/code\u003e, providing access to these functions.\u003c/p\u003e\n"],["\u003cp\u003eThere is a section, "Mocking the Cloud Bigtable C++ Client with Google Mock", that provides a comprehensive example on mocking \u003ccode\u003eTable\u003c/code\u003e calls.\u003c/p\u003e\n"]]],[],null,["# Class MockDataConnection (2.21.0)\n\nVersion 2.21.0keyboard_arrow_down\n\n- [2.42.0-rc (latest)](/cpp/docs/reference/bigtable/latest/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.41.0](/cpp/docs/reference/bigtable/2.41.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.40.0](/cpp/docs/reference/bigtable/2.40.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.39.0](/cpp/docs/reference/bigtable/2.39.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.38.0](/cpp/docs/reference/bigtable/2.38.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.37.0](/cpp/docs/reference/bigtable/2.37.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.36.0](/cpp/docs/reference/bigtable/2.36.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.35.0](/cpp/docs/reference/bigtable/2.35.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.34.0](/cpp/docs/reference/bigtable/2.34.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.33.0](/cpp/docs/reference/bigtable/2.33.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.32.0](/cpp/docs/reference/bigtable/2.32.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.31.0](/cpp/docs/reference/bigtable/2.31.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.30.0](/cpp/docs/reference/bigtable/2.30.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.29.0](/cpp/docs/reference/bigtable/2.29.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.28.0](/cpp/docs/reference/bigtable/2.28.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.27.0](/cpp/docs/reference/bigtable/2.27.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.26.0](/cpp/docs/reference/bigtable/2.26.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.25.1](/cpp/docs/reference/bigtable/2.25.1/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.24.0](/cpp/docs/reference/bigtable/2.24.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.23.0](/cpp/docs/reference/bigtable/2.23.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.22.1](/cpp/docs/reference/bigtable/2.22.1/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.21.0](/cpp/docs/reference/bigtable/2.21.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.20.0](/cpp/docs/reference/bigtable/2.20.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.19.0](/cpp/docs/reference/bigtable/2.19.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.18.0](/cpp/docs/reference/bigtable/2.18.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.17.0](/cpp/docs/reference/bigtable/2.17.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.16.0](/cpp/docs/reference/bigtable/2.16.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.15.1](/cpp/docs/reference/bigtable/2.15.1/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.14.0](/cpp/docs/reference/bigtable/2.14.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.13.0](/cpp/docs/reference/bigtable/2.13.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.12.0](/cpp/docs/reference/bigtable/2.12.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection)\n- [2.11.0](/cpp/docs/reference/bigtable/2.11.0/classgoogle_1_1cloud_1_1bigtable__mocks_1_1MockDataConnection) \nA class to mock [`google::cloud::bigtable::DataConnection`](/cpp/docs/reference/bigtable/2.21.0/classgoogle_1_1cloud_1_1bigtable_1_1DataConnection). \nApplication developers may want to test their code with simulated responses, including errors from a [`bigtable::Table`](/cpp/docs/reference/bigtable/2.21.0/classgoogle_1_1cloud_1_1bigtable_1_1Table). To do so, construct a [`bigtable::Table`](/cpp/docs/reference/bigtable/2.21.0/classgoogle_1_1cloud_1_1bigtable_1_1Table) with an instance of this class. Then use the Google Test framework functions to program the behavior of this mock.\n\nSee [Mocking the Cloud Bigtable C++ Client with Google Mock](/cpp/docs/reference/bigtable/2.21.0/bigtable-mocking) for a complete example that mocks `Table` calls.\n\nConstructors\n------------\n\n### MockDataConnection()\n\nFunctions\n---------\n\n### virtual options()\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual Apply(std::string const \\&, SingleRowMutation)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual AsyncApply(std::string const \\&, SingleRowMutation)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual BulkApply(std::string const \\&, BulkMutation)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual AsyncBulkApply(std::string const \\&, BulkMutation)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual ReadRows(std::string const \\&, RowSet, std::int64_t, Filter)\n\nPrefer to use [`ReadRowsFull()`](/cpp/docs/reference/bigtable/2.21.0/classgoogle_1_1cloud_1_1bigtable_1_1DataConnection#classgoogle_1_1cloud_1_1bigtable_1_1DataConnection_1a6d020c8d2a384ab2c09ee643aa01900e) in mocks. \nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual ReadRowsFull(ReadRowsParams)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual ReadRow(std::string const \\&, std::string, Filter)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual CheckAndMutateRow(std::string const \\&, std::string, Filter, std::vector\\\u003c Mutation \\\u003e, std::vector\\\u003c Mutation \\\u003e)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual AsyncCheckAndMutateRow(std::string const \\&, std::string, Filter, std::vector\\\u003c Mutation \\\u003e, std::vector\\\u003c Mutation \\\u003e)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual SampleRows(std::string const \\&)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual AsyncSampleRows(std::string const \\&)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual ReadModifyWriteRow(google::bigtable::v2::ReadModifyWriteRowRequest)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual AsyncReadModifyWriteRow(google::bigtable::v2::ReadModifyWriteRowRequest)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual AsyncReadRows(std::string const \\&, std::function\\\u003c future\\\u003c bool \\\u003e(Row)\\\u003e, std::function\\\u003c void(Status)\\\u003e, RowSet, std::int64_t, Filter)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests.\n\n### virtual AsyncReadRow(std::string const \\&, std::string, Filter)\n\nThis function is implemented using [gMock](https://google.github.io/googletest)'s `MOCK_METHOD()`.\nConsult the gMock documentation to use this mock in your tests."]]