Esun Kim e52081f903 More pythons to be formatted 5 лет назад
..
client a6dbc7adb5 rename spiffe to tls 5 лет назад
cocoapods 7ec6e8a4de Remove nanopb from gRPC 6 лет назад
codegen 8d9d8326f5 De-experimentalize generated code 5 лет назад
common 618771dc6a [Exposing ALTS Context 2/2] Utility Wrapper Class 5 лет назад
end2end 027eb3b05b Merge pull request #21532 from vjpai/deadline 5 лет назад
ext 2e958cf01b (Census client filter: use current span and tags. original_author=g-easy) 5 лет назад
grpclb ef050280af Clean up APIs for handling grpclb protos 5 лет назад
interop c34bef4ca4 Format all Bazel files with buildifier 5 лет назад
ios 63223f82e8 fix sanity 5 лет назад
microbenchmarks d5d6914751 Make buildifier sanity test fail-able 5 лет назад
naming e52081f903 More pythons to be formatted 5 лет назад
performance c34bef4ca4 Format all Bazel files with buildifier 5 лет назад
qps e52081f903 More pythons to be formatted 5 лет назад
server c34bef4ca4 Format all Bazel files with buildifier 5 лет назад
test c34bef4ca4 Format all Bazel files with buildifier 5 лет назад
thread_manager c34bef4ca4 Format all Bazel files with buildifier 5 лет назад
util c34bef4ca4 Format all Bazel files with buildifier 5 лет назад
README-iOS.md b436758b14 Added documentation for C++ tests on iOS 6 лет назад

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.