constructor_InitiallyZero
. (We're testing the constructor, and ensuring that the value is initially zero, and the name will remind us of that.) The red "recording light" should be on, which means BlueJ will watch everything you do from this point onward, whether it's in the codepad or pointing-and-clicking, and build it in to the test.
Go ahead and repeat the test process: Create a NumberDisplay object, then call getValue on it. This time around, the resulting box looks a little different. BlueJ says the method has returned a zero, but it wants to know if it should always expect a zero there (and complain if it's not). Make sure the "Assert that" box is checked, enter a 0 in the box, then click Close. That's the end of this test, so click the "End" button under the recording indicator. Now if you look in the NumberDisplayTest class you'll see the new method at the bottom of the code. After compiling, you can right-click on the NumberDisplayTest class and "Test All" to run the new test, or click the "Run Tests" button on the left edge of the project window.
constructor_InitialDisplay
:
increment_InitialIncrement
:
increment_MultipleIncrements
:
increment_Wraps
:
setValue_LegalValues
:
setValue_IllegalValues
:
displayString_SingleDigit
:
displayString_DoubleDigit
:
Make sure all of these tests run successfully before proceeding.
constructor_InitialTime
:
setTime_SingleDigits
:
setTime_DoubleDigits
:
constructor_SpecifiedTimes
:
timeTick_minutesOnly
:
timeTick_minutesAndHours
:
timeTick_bothRollOver
:
value < 10
to value <= 10
. Then try value < 9
too.
((replacementValue >= 0) && (replacementValue < limit))
, try using an or (||
) rather than and (&&
). Try using > vs >= or <= vs <.
equals
method to NumberDisplay that takes another NumberDisplay and returns true if the two are the same (have the same value and wrap-around limit). Then think about how to test equals
via unit tests.