你如何为“make check"创建测试?使用 GNU 自动工具 [英] How do you create tests for "make check" with GNU autotools

查看:34
本文介绍了你如何为“make check"创建测试?使用 GNU 自动工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为特定项目的构建系统使用 GNU 自动工具.我想开始编写用于验证的自动化测试.我只想输入make check"让它自动运行这些.我的项目是用 C++ 编写的,尽管我仍然对为其他语言编写自动化测试感到好奇.

I'm using GNU autotools for the build system on a particular project. I want to start writing automated tests for verifcation. I would like to just type "make check" to have it automatically run these. My project is in C++, although I am still curious about writing automated tests for other languages as well.

这是否与几乎所有的单元测试框架兼容(我正在考虑使用 cppunit)?如何将这些单元测试框架挂钩到 make check 中?我可以确保不需要安装单元测试软件就可以配置和构建项目的其余部分吗?

推荐答案

要在发出 make check 时进行测试,需要将它们添加到 TESTS 变量中

To make test run when you issue make check, you need to add them to the TESTS variable

假设您已经构建了运行单元测试的可执行文件,您只需将可执行文件的名称添加到 TESTS 变量中,如下所示:

Assuming you've already built the executable that runs the unit tests, you just add the name of the executable to the TESTS variable like this:

TESTS=my-test-executable

它应该会在您make check时自动运行,如果可执行文件返回一个非零值,它将报告测试失败.如果您有多个单元测试可执行文件,只需将它们全部列在 TESTS 变量中:

It should then be automatically run when you make check, and if the executable returns a non-zero value, it will report that as a test failure. If you have multiple unit test executables, just list them all in the TESTS variable:

TESTS=my-first-test my-second-test my-third-test

他们都会跑起来.

这篇关于你如何为“make check"创建测试?使用 GNU 自动工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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