Qixuan Li dcff8b78ec Merge pull request #20612 from qixuanl1/add-more-logging hace 6 años
..
client d874a260bb Fix unused variable error hace 6 años
cocoapods 7ec6e8a4de Remove nanopb from gRPC hace 6 años
codegen 6ebc1c616f set uses_polling=False for some bazel tests hace 6 años
common 3080419c90 temporarily disable alarm_test hace 6 años
end2end 9a276c07fa Revert "Merge pull request #20593 from grpc/revert-20380-xds_client_bootstrap" hace 6 años
ext 5cc45de443 disable some broken test on windows RBE hace 6 años
grpclb c6b0bd08c7 Updated grpclb to use upb hace 6 años
interop 6a89c0e57e Add more logging to channel_soak interop test to indicate the boundary of an iteration hace 6 años
ios eae902594b Merge pull request #19855 from Tony1023/bazel_objc_tests hace 6 años
microbenchmarks 0a57e9cc69 Fix bm chttp2 transport hace 6 años
naming 39e982a263 Merge pull request #19488 from soheilhy/string-view2 hace 6 años
performance 40210d3b8a Move Channel to grpc_impl hace 6 años
qps 04d7e0d11f Revert "Upgrade to bazel 1.0.0" hace 6 años
server 732e2a1e90 Tune load reporter test hace 6 años
test 67742ef63f Fix BUILD files. Manually edit bzl files hace 6 años
thread_manager 67742ef63f Fix BUILD files. Manually edit bzl files hace 6 años
util f12df974ae Merge pull request #20401 from tanjunchen/clean-up hace 6 años
README-iOS.md b436758b14 Added documentation for C++ tests on iOS hace 6 años

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.