Building a unit test target with GNUstep make

Just a quick note on how I build my test tools (they run separately, either by manual invocation or via CI) when I’m working in GNUstep.

Firstly, you’ll need Catch. Then given test files that look like this:
#include "catch.hpp"

TEST_CASE("Using foundation", "I should be able to use Foundation classes from a test tool")
  NSArray *array = [NSArray array];
  REQUIRE([array count] == 0);

(only one of your files should define CATCH_CONFIG_MAIN as you must only have one main function).

Then I define a tests target in my Makefile:


include $(GNUSTEP_MAKEFILES)/common.make

#… stuff to define my app target


-include Makefile.preamble

#… include target definitions for the app target
include $(GNUSTEP_MAKEFILES)/test-tool.make

-include Makefile.postamble

And there it is. Now whenever I make my app I also get obj/tests which’ll run the test suite for me.

About Graham

I make it faster and easier for you to create high-quality code.
This entry was posted in TDD. Bookmark the permalink.