Lab One, Group Four: Brian Smyth and Richard Geary

Lab 1 notebook (Richard Geary and Brian Smyth)


The key class in JUnit is the TestCase. Whenever implementing one's own test cases, the class should extend TestCase. Within that class should be methods named test{something}. These methods are automatically run by one of JUnit's test runners. The class should also contain setUp and tearDown methods that intialize and clean up (respectively) after each test.

The key concept within a test method is the assert{whatever} method call. Within this method call, the tester should make sure that the result of the tested action is consistent with what he believes the outcome should be. There are many different assert methods, so different combinations and types of values can be passed and tested.

Obstacles triumphantly overcome:
  • Had to set $path to include local Java binaries. (
    set path = ( /usr/local/j2sdk1.4.0/bin/ $path
    ) in CSH )
  • JWhich didn't work properly from sol (because /net/jutils was not in classpath). Set classpath to recognize the directories under /net/jutils/ (
    set classpath = /net/jutils/JWhich /net/jutils/junit3.7/
    ).
  • At 10:35AM (according to alden108 time), we were fed up with Java.
  • The JUnit MoneyTest sample had package directives that were screwy. Once removed, MoneyTest ran.
  • The command to run a Swing-based test is:
    java junit.swingui.TestRunner [testcase]
    .
  • We use database bankDB108.
  • To use javap with a class inside a package: from the directory that contains the name of the package, run
    javap packagename.classname
    .
  • We needed to remember to import TransactionAgent.MySQLDatabase.
  • All of our tests need to declare that they throw a bunch of exceptions.
  • We found an error in accountWithdraw (it adds the amount instead of subtracting).
  • We found an error in accountExists (it seems to return the id + 1).
  • testDelete passes, but after the first run, the account is never there. It's curious that deleteAccount does not throw and Exception when you try to delete (again) an account that doesn't exist.

Link to this Page