Junilu, When I run the step 4 test code, I get a NullPointerException at the line: assertTrue("0".equals(calc.getResult())); It seems "calc" is not getting initialized in setUp(). Actually, I think setUp() isn't getting run at all: I added assertTrue( false ) ; after the assignment and it runs fine.

Michael Matola
whippersnapper
Ranch Hand

Joined: Mar 25, 2001
Posts: 1759

3

posted Mar 13, 2002 19:31:00

0

Also, could you explain the method void assertEquals( double expected ,double actual , double delta ) I'm not sure I understand the point of the delta parameter.

Michael, I'm not sure what's going on with the NullPointerException. setUp() is invoked before each testXXX() method and you could try putting a System.out.println just to prove to yourself that it's actually invoked. Try compiling both classes again. And make sure you don't have any stray .class files with the same names lying around your classpath. As for delta: by nature, floating point comparisons are imprecise. 'delta' is the degree of tolerance for slight differences in the expected and actual values. If the difference is greater than the tolerance then the assertion will fail. In the Step 7 test, we have specified a 0.0 tolerance. Junilu

Michael Matola
whippersnapper
Ranch Hand

Joined: Mar 25, 2001
Posts: 1759

3

posted Mar 14, 2002 19:13:00

0

I'm all sorted out. Since we weren't very far along, I just deleted everything and started over. No exceptions thrown this time, so I'm all caught up. By the way, adding print statements to setUp() didn't help (tried that even before I posted). JUnit must be redirecting standard output somewhere, but I haven't figured out where yet. That's why I had to add assertTrue( false ) ; originally to verify that setUp() was being called.