简体   繁体   English

C ++-Google测试-如何在不同目录中并行运行所有测试?

[英]C++ - Google Test - How to run all tests in different directories in parallel?

I am working on a C++ project with numerous test folders generated by Google test platform. 我正在使用一个C ++项目,其中包含Google测试平台生成的大量测试文件夹。 For example after making the project, I will have the following executable test files, each containing multiple test suites: 例如,在创建项目之后,我将拥有以下可执行的测试文件,每个文件包含多个测试套件:

/proj/build/interface/test/test1_executable
/proj/build/interface/test/test2_executable
/proj/build/module2/test/test1_executable
/proj/build/module2/test/test2_executable

I would like to run all tests after a new build. 我想在新构建后运行所有测试。 Is these a way to run all of these files at one once, hopefully in parallel? 这些方法可以一次运行所有这些文件,还是希望并行运行吗?

Python has a utility called nosetests that can run of the tests in a project. Python有一个称为nosetests测试的实用程序,可以在项目中运行测试。 How do C++ programmers run all tests in a project? C ++程序员如何在项目中运行所有测试?

This looks like you are creating one binary per test. 看起来您正在为每个测试创建一个二进制文件。 That is not how you should use googletest. 那不是您应该使用googletest的方式。

If you write a single main function , you have a single binary with all tests. 如果编写单个main函数 ,则所有测试都只有一个二进制文件。 You can still select single tests by adding --gtest_filter=whatever . 您仍然可以通过添加--gtest_filter=whatever选择单个测试。

"How do C++ programmers run all tests in a project?" “ C ++程序员如何在项目中运行所有测试?” - That depends entirely on the test framework and build system used. -这完全取决于所使用的测试框架和构建系统。 There is no standardized solution. 没有标准化的解决方案。

In Windows, create a batch file and prepend the word START to each line: 在Windows中,创建一个批处理文件,并在每行前面加上单词START:

START /proj/build/interface/test/test1_executable
START /proj/build/interface/test/test2_executable
START /proj/build/module2/test/test1_executable
START /proj/build/module2/test/test2_executable

In Linux, append a & at the end of each line of the batch file: 在Linux中,在批处理文件每一行的末尾添加&:

/proj/build/interface/test/test1_executable&
/proj/build/interface/test/test2_executable&
/proj/build/module2/test/test1_executable&
/proj/build/module2/test/test2_executable&

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM