gtest-parallel-cpp is a the single header library to the separate Compilation and parallel execution of the GoogleTest written in C++ and OpenMP. Each test is run independently for each test case. Execution results are displayed in order.
gtest-parallel-cpp は,GoogleTest を並列コンパイル・並列実行するための C++ で書かれたシングルヘッダライブラリです.各テストはテストケースごとに独立に実行されます.実行結果は,順序を守って表示されます.
- Copy the
gtest_parallel
directory - Add the following header and execution definition to the test code written in Googletest.
#include "../gtest_parallel/test_main.hpp"
EXECUTE_TESTS(); // Write in the bottom of test code.
- Compile your test code
- Write the entry point of gtest-parallel-cpp and write the executing binary path.
#include "gtest_parallel/gtest_parallel.hpp" int main(int argc, char** argv){ printf("\n"); printf("+---------------------------------------------------+\n"); printf("| |\n"); printf("| Welcome to the Sample of |\n"); printf("| Separate Compilation and Parallel Execution |\n"); printf("| of the googletest |\n"); printf("| |\n"); printf("+---------------------------------------------------+\n"); printf("\n"); std::string base_path = "./tmpMake/test"; // Testing binaries std::vector<std::string> vExePath; vExePath.push_back(base_path+"/"+"example_math.exe " ); // replace your binary path vExePath.push_back(base_path+"/"+"example_strEdit.exe "); // replace your binary path int ret = gtest_parallel::run_tests(vExePath); return ret; }
- Compile entry point of gtest-parallel-cpp and execute.
Note: Adding a-fopenmp
option is required.
See GitHub Actions.
TEST(testCaseName, testName){
const auto* test_info = testing::UnitTest::GetInstance()->current_test_info();
printf("%s\n", test_info->test_case_name());
printf("%s\n", test_info->name() );
}
OR
TEST(testCaseName, testName){
printf("%s\n", test_info_->test_case_name());
printf("%s\n", test_info_->name() );
}