|
vor 3 Wochen | |
---|---|---|
.. | ||
client | vor 3 Wochen | |
cocoapods | vor 3 Wochen | |
codegen | vor 3 Wochen | |
common | vor 3 Wochen | |
end2end | vor 3 Wochen | |
ext | vor 3 Wochen | |
grpclb | vor 3 Wochen | |
interop | vor 3 Wochen | |
ios | vor 3 Wochen | |
microbenchmarks | vor 3 Wochen | |
naming | vor 3 Wochen | |
performance | vor 3 Wochen | |
qps | vor 3 Wochen | |
security | vor 3 Wochen | |
server | vor 3 Wochen | |
test | vor 3 Wochen | |
thread_manager | vor 3 Wochen | |
util | vor 3 Wochen | |
README-iOS.md | vor 3 Wochen |
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.
Please follow these guidelines when porting tests to run on iOS:
main
needs to be moved to SetUpTestCase
/TearDownTestCase
, and TEST
needs to be changed to TEST_F
.*_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();
}
Due to a limitation in GTMGoogleTestRunner, SetUpTestCase
/TeardownTestCase
will be called before/after every individual test case, similar to SetUp
/TearDown
.