Description
During this lab you will run a JUnit test suite and
add a JUnit test to it.
The test will make use of mock objects. Then
you will make changes to an existing Ant build file.
Task 0
Checkout a working copy of your project and change to
the working copy directory.
-
build the application and the tests by executing ant compile-test.
-
copy of the file classpath.txt
in your current working directory.
-
set the class path (e.g. if you use bash do the following)
-
export CLASSPATH=`cat classpath.txt`
-
run the tests executing
java org.junit.runner.JUnitCore edu.ucsd.cse70.ircclient.IRCClientTest
and
java org.junit.runner.JUnitCore edu.ucsd.cse70.ircclient.IRCMessageTest
-
run the tests using Ant (ant test)
-
clean up with ant clean.
-
Rerun the tests within Eclipse.
Task 1
Write a JUnit test for the IRCClient class that uses
mock objects. To the IRCClientTest, add a JUnit test called
testServerNickMessageWithInUseError. The test
represents an invocation of the /nick command
to which the server replies with a ERR_NICKNAMEINUSE.
Task 2
Modify the Ant build file. When you are done,
only the targets listed below may be defined.
-
compile: compile the Java files under the src
directory. The class files are stored in the classes
directory.
-
compile-test: compile the Java files under the test
directory. The class files are stored in the suite
directory. This target depends on compile.
-
jar: build a jar for the application. This target depends
on compile.
-
test: run all the tests. Dependencies should be set appropriately.
-
run: run the application from the jar.
Dependencies should be set appropriately.
-
all: builds the application and creates the jar file, runs the
tests, and then runs the application. Dependencies should be set appropriately.
-
clean: restores the initial state of
source tree removing all the directories and files created.
clean depends on clean-compile,
clean-jar, and clean-test.
-
clean-compile: removes all the class files and the
classes directory.
-
clean-jar: removes the jar directory and
the jar file that it contained.
-
clean-test: removes the suite directory and
the class files that it contained.
Check List
-
How to write a JUnit test and use JMock mock objects.
-
How to read and write an Ant build file, define targets,
and their dependencies.
Useful Links