help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with prerequisites for unit testing rule


From: Björn Lindström
Subject: Re: Help with prerequisites for unit testing rule
Date: Mon, 14 Feb 2005 11:50:28 +0100
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.3 (gnu/linux)

It seems the solution I arrived at after my last question didn't
completely do the trick.

I now have this:

----
CLASSPATH := .:/usr/share/java/junit.jar

JAVAC := javac -classpath $(CLASSPATH)
JUNIT := java -classpath $(CLASSPATH) junit.textui.TestRunner

CLASSES :=  BetterTray.class BinTree.class BinTree2.class Queue.class
TESTCLASSES := $(CLASSES:%=Test%)

all: $(CLASSES)

BinTree.class: Queue.class
BinTree2.class: BetterTray.class
%.class: %.java
        $(JAVAC) $<

test: $(TESTCLASSES)
$(TESTCLASSES): Test%: %
        $(JUNIT) $(patsubst %.class,%,$@)

.PHONY: clean

clean:
        rm -f $(CLASSES) $(CLASSES:%=Test%)
----

Now, if I run 'make test', make will start out building
BetterTray.class, like it should, and then go on to run $(JUNIT) on
TestBetterTray.class. So, what's missing is that it doesn't actually
build TestBetterTray.class in between those steps. How would I make the

$(TESTCLASSES): Test%: %

rule also depend on the build rule for the corresponding test class?
(The %.class: %.java rule.)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]