SE 3M04 T1 2002
Assignment 2a - Final Version (Mon. Sep 30)
- Due: Friday October 4, 14:00 through WebCT
- Goals:
- Learn about testing
- Learn about modularization
-
- Rewrite your Java program from assignment 1a to
- Be divided in (at least) 9 classes. You must use the
classes provided in source form in
assignment2.zip as a starting point
; you may not change the signatures of
the methods already provided. You must add the code to implement
those methods that are not already implemented. You may add methods
(and classes) if you need them. Note that an example class
Capacitor is provided and that you are expected to use it as a model
for the other components.
- The output of your program when run on ex1.cir, ex2.cir, ex3.cir,
ex4.cir and ex5.cir must *exactly* match (respectively) correct1.txt, correct2.txt,
correct3.txt, correct4.txt and correct5.txt. These files are also
contained in assignemtn2 zip file.
- You may use as much code from the posted solution to the first assignment
as you wish, as long as you indicate this in your log.
- Create a JUnit test class (ie a class that extends JUnit's TestCase) for
each one of your program classes, as well as one Test suite for the whole program.
See Course Java page for details on JUnit.
- Every (non-private) method of each class should be tested.
- There should be tests for both correct and incorrect calls to each methods
- Deliverables:
- clear text file with exact requirements.
- java program file(s), including all the test classes
- must run cleanly through TestRunner
- electronic copy of log
- It is expected that in total you will have 18+ classes (9 program, 9 test).
- To be delivered electronically through your WebCT account
- Notes:
- The routines in package ca.mcmaster.se3m04 must be in a
sub-directory ca/mcmaster/se3m04 of where assignment2.java is for it
to be found properly.
- To fully compile the package first:
javac ca/mcmaster/se3m04/*.java
- Compile assignement 2:
javac assignment2.java
- Make sure that none of the .java files in ca/mcmaster/se3m04, nor any
of the corresponding .class files are in the same directory as
assignment2.java, this will cause things to not work
- Whenever you make changes to the package files, you must recompile it
first, and then assignment2.java for all the changes to take effect.
- See Compiling Java Package
for a longer discussion of this and some alternate ways of accomplishing
the same result.
- Installing JUnit:
- Assumptions: windows and previously empty classpath
- Let INSTALL_DIR be the directory where you installed JUnit
- Type in the following:
set classpath=INSTALL_DIR;INSTALL_DIR\junit.jar;.
where you have to replace INSTALL_DIR by the actual correct directory name.
You can also put that line into your autoexec.bat (if using an Windows 95/98/ME)
or put it in your environment variables (editable through the control panel for
Windows NT/2000/XP).
- java junit.textui.TestRunner junit.samples.AllTests
should now work correctly.
- There is a test2.java file in assignment2.zip which is an example of
using junit to write 1 test the Capacitor class. Many more are expected.
Back to main page