Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • Change the name of the stub method testX() in the above to test_nMonthTillBD()and add code to make it look like the code below.
    Code Block
    class Test_PersonextendsTestCase {
     void test_nMonthTillBD() {
       Person peter =newPerson(9);// a person born in September.
       assertEquals("Calling nMonthTillBD(2).", 7, peter.nMonthTillBD(2)); 
       assertEquals("Calling nMonthTillBD(9).", 0, peter.nMonthTillBD(9)); 
       assertEquals("Calling nMonthTillBD(12).", 9, peter.nMonthTillBD(12));
     } 
    }
    
    Note that in the code for test_nMonthTillBD(), we have decided that we only need to know the birth month of a person in order to compute the number of months till the next birth day. As a result, we instantiate a Person object by passing only the birth month: new Person(9).

...