Automake: run unit tests automatically

I support the autoconf package and want to integrate automated testing. I use the Boost Unit Test Framework for my unit tests and have been able to successfully integrate it into the package.

That is, it can be compiled using make check , but it fails (although I read that make check compiles and runs tests). As a result, I have to run it manually after creating tests that are bulky.

Makefile.am in the test folder is as follows:

 check_PROGRAMS = prog_test prog_test_SOURCES = test_main.cpp ../src/class1.cpp class1_test.cpp class2.cpp ../src/class2_test.cpp ../src/class3.cpp ../src/class4.cpp prog_test_LDADD = $(BOOST_FILESYSTEM_LIB) $(BOOST_SYSTEM_LIB) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) 

Makefile.am in the root folder:

 SUBDIRS = src test dist_doc_DATA = README ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS} -I m4 

Running test/prog gives the result:

 Running 4 test cases... *** No errors detected 

(I don't think you need the contents of my test cases to answer my question, so I skipped them for now)

So, how can I get automake to run my tests every time I run make check ?

+5
source share
1 answer

At least one way to do this involves setting the TESTS variable. Here's what the automake documentation says about this:

If a special TESTS variable is defined, its value is considered a list of programs or scripts to run for testing.

So by adding a line

 TESTS = $(check_PROGRAMS) 

should instruct him to run make check tests.

+8
source

All Articles