Mark D. Roth 09b42371e7 Remove grpc_core::InlinedVector<> and grpc_core::Optional<>. hace 5 años
..
client 09b42371e7 Remove grpc_core::InlinedVector<> and grpc_core::Optional<>. hace 5 años
cocoapods 7ec6e8a4de Remove nanopb from gRPC hace 6 años
codegen c86cfc305c Remove all std::mem_fn and std::bind from service definitions and setup hace 5 años
common 380a362417 dont build time_jump_test on windows hace 5 años
end2end c3f5c02276 Merge branch 'master' into uselogicalthread hace 5 años
ext 2e958cf01b (Census client filter: use current span and tags. original_author=g-easy) hace 5 años
grpclb ef050280af Clean up APIs for handling grpclb protos hace 5 años
interop 331b332392 Try fixing interop tests hace 5 años
ios eb7779c20c Revert "Revert "Introduce CFRunLoop based iomgr"" hace 5 años
microbenchmarks 527509abc4 Unmark flaky on streaming_pump hace 5 años
naming 00458b3851 Merge branch 'master' into uselogicalthread and address reviewer hace 5 años
performance 5bc57b64fe InitGoogleTest before grpc_init hace 5 años
qps 962a8f28f9 Add a flag to set a grpclb+pick_first service config in hace 5 años
server 415d41f9e8 Rerun clang-formatter-7 hace 5 años
test c34bef4ca4 Format all Bazel files with buildifier hace 6 años
thread_manager c34bef4ca4 Format all Bazel files with buildifier hace 6 años
util 7cb9d43da2 Merge pull request #22689 from grpc/zhen_core_test_improvement_7 hace 5 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.