相关疑难解决方法(0)

如何将参数传递给gtest

如何将参数传递给我的测试套件?

gtest --number-of-input=5
Run Code Online (Sandbox Code Playgroud)

我有以下主要的gtest代码.并且--number-of-input=5应该传递给InitGoogleTest().

#include <iostream>
#include <gtest/gtest.h>

int main(int argc, char **argv) {
  std::cout << "Running main() from gtest_main.cc\n";
  ::testing::GTEST_FLAG(output) = "xml:hello.xml";
  testing::InitGoogleTest(&argc, argv);

  return RUN_ALL_TESTS();
}
Run Code Online (Sandbox Code Playgroud)

我不知道如何将我的参数传递给测试套件/案例如下?

class TestTwo : public QuickTest {
 protected:
  virtual void SetUp() {
      QuickTest::SetUp();
      square = new Square(10);
      circle = new Circle(10);

  }

  virtual void TearDown() {
      delete square;
      delete circle;
      QuickTest::TearDown();
  }

  Square* square;
  Circle* circle;
};


// Now, let's write tests using the QueueTest fixture.

// Tests the default …
Run Code Online (Sandbox Code Playgroud)

c++ unit-testing googletest

32
推荐指数
1
解决办法
3万
查看次数

我可以将参数传递给googletest测试功能吗?

在构建我的测试文件xxxxtest之后,使用gtest可以在运行测试时传递参数,例如./xxxxtest 100.我想使用参数控制我的测试功能,但我不知道如何在我的测试中使用para,你能告诉我测试中的样本吗?

c++ googletest

6
推荐指数
2
解决办法
1万
查看次数

标签 统计

c++ ×2

googletest ×2

unit-testing ×1