Writing a Makefile.am to invoke googletest unit tests

automake, c++, googletest, makefile, unit-testing

Solution

William's answer got me where I needed to go. Just for the sake of the community, here's what I ended up doing:

- I moved my tests back into the main directory structure and prepended test_, as per William's suggestions.

I added a few lines to src/audio/Makefile.am to enable unit tests:

# Unit tests
noinst_PROGRAMS = test_audio_manager

test_audio_manager_SOURCES  = $(libadonthell_audio_la_SOURCES) test_audio_manager.cc
test_audio_manager_CXXFLAGS = $(libadonthell_audio_la_CXXFLAGS)
test_audio_manager_LDADD    = $(libadonthell_audio_la_LIBADD) -lgtest

TESTS = test_audio_manager

Now, running "make check" fires the unit tests!

All of this can be seen here: http://github.com/ksterker/adonthell/commit/aacdb0fe22f59e61ef0f5986827af180c56ae9f3

Problem

I am trying to add my first unit test to an existing Open Source project. Specifically, I added a new class, called audio_manager: ``` src/audio/audio_manager.h src/audio/audio_manager.cc ``` I created a src/test directory structure that mirrors the structure of the implementation files, and wrote my googletest unit tests: ``` src/test/audio/audio_manager.cc ``` Now, I am trying to set up my Makefile.am to compile and run the unit test: ``` src/test/audio/Makefile.am ``` I copied Makefile.am from: ``` src/audio/Makefile.am ``` Does anyone have a simple recipe for me, or is it to the cryptic automake documentation for me? :)

Original source