Esun Kim 377fe6095a Upgrade clang-tidy and clang-format to 11 (#25590) преди 4 години
..
client 377fe6095a Upgrade clang-tidy and clang-format to 11 (#25590) преди 4 години
cocoapods 86050be0cf Clean up DEPLOYMENT_TARGET преди 5 години
codegen 27e1c1c56d clang-tidy: enable google-readability-braces-around-statements преди 4 години
common 1835f00ef1 Revert "Revert "Made grpc_core::Mutex compatible to absl::Mutex" (#25537)" (#25549) преди 4 години
end2end 377fe6095a Upgrade clang-tidy and clang-format to 11 (#25590) преди 4 години
ext 9bd7c4917a Fix unused-parameter warning преди 4 години
grpclb 62ac3f075a Added call to grpc::testing::TestEnvironment in tests преди 5 години
interop 377fe6095a Upgrade clang-tidy and clang-format to 11 (#25590) преди 4 години
ios f4e55b85bc Replace disrespectful term преди 4 години
microbenchmarks 0e3a02e903 Revert "Remove the `urgent` argument from iomgr tcp read API (#25494)" (#25592) преди 4 години
naming f4e55b85bc Replace disrespectful term преди 4 години
performance e7434d385e Fix by tidy-modernize-use-override преди 5 години
qps 377fe6095a Upgrade clang-tidy and clang-format to 11 (#25590) преди 4 години
server f171a6689e Fix StatusCode преди 4 години
test 165ee5007a Replaced grpc::string with std::string преди 5 години
thread_manager 131579d52d Roll forward of commit 7883b51: Use abseil's flags in tests. преди 4 години
util f4e55b85bc Replace disrespectful term преди 4 години
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.