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存在。