Esun Kim a62a70207c Merge pull request #24448 from veblush/clang-format-8 5 ani în urmă
..
client b62d5c7eaa Allow channel args to modify service config parsing behavior. 5 ani în urmă
cocoapods 86050be0cf Clean up DEPLOYMENT_TARGET 5 ani în urmă
codegen 25cbc854d2 Fix compiler_test_golden 5 ani în urmă
common 8e9e895ffc Replace grpc_shutdown_blocking with grpc_shutdown 5 ani în urmă
end2end 1bb28c90b2 Merge pull request #24436 from markdroth/xds_resource_version 5 ani în urmă
ext e7434d385e Fix by tidy-modernize-use-override 5 ani în urmă
grpclb 62ac3f075a Added call to grpc::testing::TestEnvironment in tests 5 ani în urmă
interop e7434d385e Fix by tidy-modernize-use-override 5 ani în urmă
ios 86050be0cf Clean up DEPLOYMENT_TARGET 5 ani în urmă
microbenchmarks a62a70207c Merge pull request #24448 from veblush/clang-format-8 5 ani în urmă
naming 6ae8463500 Fix by modernize-make-unique 5 ani în urmă
performance e7434d385e Fix by tidy-modernize-use-override 5 ani în urmă
qps 84df61b31a Merge pull request #24453 from veblush/tidy-modernize-make-unique 5 ani în urmă
server 6ae8463500 Fix by modernize-make-unique 5 ani în urmă
test 165ee5007a Replaced grpc::string with std::string 5 ani în urmă
thread_manager c34bef4ca4 Format all Bazel files with buildifier 6 ani în urmă
util a62a70207c Merge pull request #24448 from veblush/clang-format-8 5 ani în urmă
README-iOS.md b436758b14 Added documentation for C++ tests on iOS 6 ani în urmă

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.