Gogs bef6e57d0d first commit 3 долоо хоног өмнө
..
client bef6e57d0d first commit 3 долоо хоног өмнө
cocoapods bef6e57d0d first commit 3 долоо хоног өмнө
codegen bef6e57d0d first commit 3 долоо хоног өмнө
common bef6e57d0d first commit 3 долоо хоног өмнө
end2end bef6e57d0d first commit 3 долоо хоног өмнө
ext bef6e57d0d first commit 3 долоо хоног өмнө
grpclb bef6e57d0d first commit 3 долоо хоног өмнө
interop bef6e57d0d first commit 3 долоо хоног өмнө
ios bef6e57d0d first commit 3 долоо хоног өмнө
microbenchmarks bef6e57d0d first commit 3 долоо хоног өмнө
naming bef6e57d0d first commit 3 долоо хоног өмнө
performance bef6e57d0d first commit 3 долоо хоног өмнө
qps bef6e57d0d first commit 3 долоо хоног өмнө
security bef6e57d0d first commit 3 долоо хоног өмнө
server bef6e57d0d first commit 3 долоо хоног өмнө
test bef6e57d0d first commit 3 долоо хоног өмнө
thread_manager bef6e57d0d first commit 3 долоо хоног өмнө
util bef6e57d0d first commit 3 долоо хоног өмнө
README-iOS.md bef6e57d0d first commit 3 долоо хоног өмнө

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.