We will start with testing the
Add a field that we will test against:
private InvoiceItem item;
Initialise the field in the
item = new InvoiceItem();
setUp code is a little more complicated since we need to provide values for the initial state of the object.
Add test code to the
Double result = item.getItemTotal();
Fix the imports using < Fix Imports">>.
Run the test. It should pass.
Validate the test by breaking the
getItemTotal method in the
InvoiceItem class and run the test again. You can change the
* operator to something else. The test should now fail.
Fix the method again so that the test passes.