Mark D. Roth 6ea7e4dd16 Fix channel to apply new ConfigSelector even if ServiceConfig hasn't changed. 5 vuotta sitten
..
client bd73844208 Move parse_address library from client_channel to iomgr. 5 vuotta sitten
cocoapods 165ee5007a Replaced grpc::string with std::string 5 vuotta sitten
codegen 375d92be8d Merge branch 'master' into sync-stream 5 vuotta sitten
common afda101854 cleanup bazel commands in test scripts (for non-RBE invocations) 5 vuotta sitten
end2end 6ea7e4dd16 Fix channel to apply new ConfigSelector even if ServiceConfig hasn't changed. 5 vuotta sitten
ext 2e958cf01b (Census client filter: use current span and tags. original_author=g-easy) 5 vuotta sitten
grpclb 62ac3f075a Added call to grpc::testing::TestEnvironment in tests 5 vuotta sitten
interop d10e06b60a Add interop test for special_status_message 5 vuotta sitten
ios 165ee5007a Replaced grpc::string with std::string 5 vuotta sitten
microbenchmarks 91ca04cf6f Add TestGrpcScope 5 vuotta sitten
naming bd73844208 Move parse_address library from client_channel to iomgr. 5 vuotta sitten
performance 0b61aea1c5 Convert grpc_server to idiomatic C++. 5 vuotta sitten
qps 5112d75a46 Add TestEnvironment to tests 5 vuotta sitten
server c736cf073c Added call to grpc::testing::TestEnvironment in more tests 5 vuotta sitten
test 165ee5007a Replaced grpc::string with std::string 5 vuotta sitten
thread_manager c34bef4ca4 Format all Bazel files with buildifier 6 vuotta sitten
util 91627677fd Added timeout flag to grpc cli. 5 vuotta sitten
README-iOS.md b436758b14 Added documentation for C++ tests on iOS 6 vuotta sitten

README-iOS.md

C++ tests on iOS

GTMGoogleTestRunner is used to convert googletest cases to XCTest that can be run on iOS. GTMGoogleTestRunner doesn't execute the main function, so we can't have any test logic in main. However, it's ok to call ::testing::InitGoogleTest in main, as GTMGoogleTestRunner calls InitGoogleTest. grpc::testing::TestEnvironment can also be called from main, as it does some test initialization (install crash handler, seed RNG) that's not strictly required to run testcases on iOS.

Porting exising C++ tests to run on iOS

Please follow these guidelines when porting tests to run on iOS:

  • Tests need to use the googletest framework
  • Any setup/teardown code in main needs to be moved to SetUpTestCase/TearDownTestCase, and TEST needs to be changed to TEST_F.
  • Death tests are not supported on iOS, so use the *_IF_SUPPORTED() macros to ensure that your code compiles on iOS.

For example, the following test

TEST(MyTest, TestOne) {
  ASSERT_DEATH(ThisShouldDie(), "");
}

int main(int argc, char** argv) {
  grpc::testing::TestEnvironment env(argc, argv);
  ::testing::InitGoogleTest(&argc, argv);
  grpc_init();
  return RUN_ALL_TESTS();
  grpc_shutdown();
}

should be changed to

class MyTest : public ::testing::Test {
 protected:
  static void SetUpTestCase() { grpc_init(); }
  static void TearDownTestCase() { grpc_shutdown(); }
};

TEST_F(MyTest, TestOne) {
  ASSERT_DEATH_IF_SUPPORTED(ThisShouldDie(), "");
}

int main(int argc, char** argv) {
  grpc::testing::TestEnvironment env(argc, argv);
  ::testing::InitGoogleTest(&argc, argv);
  return RUN_ALL_TESTS();
}

Limitations

Due to a limitation in GTMGoogleTestRunner, SetUpTestCase/TeardownTestCase will be called before/after every individual test case, similar to SetUp/TearDown.