谷歌测试看不到自定义标志

问题描述 投票:0回答:0

为什么谷歌测试在我输入时不设置我的标志

   --gtest_email="[email protected]" --gtest_passwd="passwd"

这是我的代码

GTEST_DEFINE_string_(email, "[email protected]", "Login to authorize to the server");
GTEST_DEFINE_string_(passwd, "passwd", "Password to authorize to the server");

class A: public ::testing::Test {
protected:
    void SetUp() override {
        email = ::testing::FLAGS_gtest_email;
        passwd = ::testing::FLAGS_gtest_passwd;
    }
};

Test_F(A, B) { ... }

int main(int argc, char** argv) {
    ::testing::InitGoogleTest(&argc, argv);
    return RUN_ALL_TESTS();
}

或者还有另一种解析命令行参数的方法吗?

c++ googletest
© www.soinside.com 2019 - 2024. All rights reserved.