2
CxxTest documentation有一个生成并运行单元测试的Makefile的例子。如何为automake(Makefile.am)做同样的事情?如何为CxxTest编写automake文件?
CxxTest documentation有一个生成并运行单元测试的Makefile的例子。如何为automake(Makefile.am)做同样的事情?如何为CxxTest编写automake文件?
我这样做是通过创建这个Makefile.am
在tests
目录,所有的测试代码为:
check_PROGRAMS = tests
EXTRA_tests_SOURCES = test_example1.hpp
EXTRA_tests_SOURCES += test_example2.hpp
tests_SOURCES = runner-autogen.cpp
BUILT_SOURCES = runner-autogen.cpp
MAINTAINERCLEANFILES = runner-autogen.cpp
runner-autogen.cpp: $(EXTRA_tests_SOURCES)
/path/to/cxxtest/bin/cxxtestgen --runner=ErrorPrinter -o [email protected] $<
这样做是编译runner-autogen.cpp
进入测试程序(称为tests
),并与make check
运行它。如果列出的任何.hpp
文件发生更改,它将运行cxxtestgen
重新创建runner-autogen.cpp
。
因为runner-autogen.cpp
被列为源文件,它会被包括在make dist
释放归档,因此除非他们改变.hpp
文件之一的用户将不再需要cxxtest存在。