testing - 执行子目录中的所有测试,即使某些测试失败

标签 testing automated-tests autotools automake regression-testing

我们利用 autotools (autoconf&automake) 基础设施在我们的软件中进行了多项回归测试。这些回归测试根据它们测试的功能/单元分为不同的子目录。我们发现,一旦其中一个子目录在任何测试中失败,接下来的子目录中的后续测试就不会执行,因此我们无法全面了解哪些功能继续按预期工作。有没有办法改变这种行为并强制执行所有测试,即使有一些测试失败?

考虑以下最小示例,其中 subdir1 失败,然后 make 检查不会继续到 subdir2。使用 make check 的输出(通过 autoreconf -fiv 和简单的 ./configure 调用生成配置后)是:

...
make[2]: Entering directory `x/subdir1'
make[3]: Entering directory `x/subdir1'
FAIL: fail
PASS: pass
make[4]: Entering directory `x/subdir1'
make[4]: Nothing to be done for `all'.
make[4]: Leaving directory `x/subdir1'
============================================================================
Testsuite summary for test 1.0
============================================================================
# TOTAL: 2
# PASS:  1
# SKIP:  0
# XFAIL: 0
# FAIL:  1
# XPASS: 0
# ERROR: 0
============================================================================
See subdir1/test-suite.log
============================================================================
make[3]: *** [test-suite.log] Error 1
make[3]: Leaving directory `x/subdir1'
make[2]: *** [check-TESTS] Error 2
make[2]: Leaving directory `x/subdir1'
make[1]: *** [check-am] Error 2
make[1]: Leaving directory `x/subdir1'
make: *** [check-recursive] Error 1

这个小测试的文件是:

configure.ac

AC_INIT([test], [1.0])
AM_INIT_AUTOMAKE()
AC_PROG_CC
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
 Makefile
 subdir1/Makefile
 subdir2/Makefile
])
AC_OUTPUT

subdir1/Makefile.am

check_PROGRAMS = fail pass
TESTS = fail pass
fail_SOURCES = fail.c
pass_SOURCES = pass.c

subdir2/Makefile.am

check_PROGRAMS = pass
TESTS = pass
pass_SOURCES = pass.c

以及fail.c和pass.c的共享源

pass.c

int main (void)
{ return 0; }

失败.c

int main (void)
{ return 1; }

最佳答案

即使某些子目标失败,要继续执行make,您可以添加-k标志 - 无论实际目标如何,这都有效:

make -k check

关于testing - 执行子目录中的所有测试,即使某些测试失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33804120/

相关文章:

python - 在 Python 中使用 virtualenv 测试我的 GAE 应用程序

reactjs - 运行k6时引用错误 : regeneratorRuntime is not defined

python - 用于 Python 的在线 IDE

linux - Autotools:使用单个 makefile 创建 32 位和 64 位库?

autotools - autoreconf 出现错误 : required file './test-driver' not found

testing - 什么是挤压测试?

python - 在参数中传递 Selenium Webdriver。在Python中可以吗?

automated-tests - 替换 Watin 的测试框架,如果它会停止维护?

java - 我不希望 assertJ assertThat 在断言失败时结束测试

c - 带有版本的 Autotool automake 输出可执行文件名