有没有办法并行运行C ++单元测试测试? [英] Is there a way to run C++ Unit Tests tests in parallel?

查看:296
本文介绍了有没有办法并行运行C ++单元测试测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在使用Boost测试已经很长时间了,我最后让我的测试运行太慢。因为每个测试是高度并行的,我希望他们与所有我的核心并发运行。

I'm using Boost Test for a long time now and I ends up having my tests running too slowly. As each test is highly parallel, I want them to run concurrently with all my cores.

有没有办法使用Boost测试库?我没有找到任何解决方案。我尝试看看如何编写自定义测试跑者,但我没有太多的文档上这一点:(

Is there a way to do that using the Boost Test Library ? I didn't found any solution. I tried to look a how to write custom test runner, but I didn't much documentation on that point :(

如果没有办法,有人知道一个好C ++测试框架来实现这个目标?我认为谷歌测试会做这项工作,但显然它不能并行运行测试即使框架有更少的功能比其他更多的已知框架,这不是一个问题,我只需要简单断言和多线程执行。

If there is no way, does someone know a good C++ Test Framework to achieve that goal ? I was thinking that Google Test would do the job but apparently it cannot run test in parallel either. Even if the framework has less features than other more known framework, it is not a problem, I just need simple assertions and multi-threaded execution.

感谢

推荐答案

可以使用 CTest 进行此操作。

CTest是与CMake(构建系统生成器)一起使用的测试驱动程序,因此您需要使用CMake来使用现有文件和测试来创建构建系统,这样您就可以使用CTest运行测试可执行文件。

CTest is the test driver which accompanies CMake (the build system generator), so you'd need to use CMake to create the build system using your existing files and tests, and in doing so you would then be able to use CTest to run the test executables.

我没有亲自使用Boost.Test与CMake(我们使用GoogleTest),但这个问题会更详细地介绍这个过程。

I haven't personally used Boost.Test with CMake (we use GoogleTest), but this question goes into a little more detail on the process.

在CMakeLists文件中添加测试后,您可以使用 CTest的 -j 参数来指定要并行运行的作业数。

Once you have the tests added in your CMakeLists file, you can make use of CTest's -j argument to specify how many jobs to run in parallel.

这篇关于有没有办法并行运行C ++单元测试测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆