CIT 591 Assignment 10: Drake Equation Notes
Fall 2008, David Matuszek

I've been getting questions today about how to test the setter methods.

Since there are no corresponding getter methods for these setter methods, it's difficult to test whether the correct value is saved. Besides, it's pretty unlikely that a setter would save the wrong value. No, there are two things for each setter method that you ought to test:

Here's how to test whether your method throws an exception when it should:

public void testSomeMethodForException() {
    // call the method in a way that should cause an exception
    // if the above call throws an exception, you will never get here

The second comment above says that, once an exception is thrown, the remaining code in the test method will never be used. So if you want to test for two or three invalid values, you need two or three test methods.

Here's how to test whether your method does not throw an exception when it should not:

public void testSomeMethod() {
    // call the method

I said that "Astronomers' best estimate of R* is in the range of 5 to 20 per year." I did not say that values outside this range should be considered illegal.

For the original Drake equation, there are two getter methods: getLifeInGalaxy and getCommunicatingCivilizations. Your DrakeGui program should display both.

For the modified Drake equation, there are two getter methods: getLifeInUniverse and getIntelligenceInUniverse. Your ModifiedDrakeGUI program should display both.

These notes are being posted the afternoon of the day that the assignment is due. Before you get annoyed about the late posting, please reflect on the fact that I get the most questions about the assignment on the day that it is due.