Question: Write a unit test to show that the InventoryTag class method addInventory ( ) has an error. First, call redSweater.addInventory ( ) with sweaterShipment as

Write a unit test to show that the InventoryTag class method addInventory() has an error. First, call redSweater.addInventory() with sweaterShipment as the argument. Then, print the following error message if the updated quantity is not the sum of sweaterInventoryBefore and sweaterShipment. Sample output for failed unit test given sweaterInventoryBefore is 0 and sweaterShipment is 5:
Beginning tests. UNIT TEST FAILED: addInventory() Tests complete.
Note: UNIT TEST FAILED is preceded by 3 spaces.
//===== Code from file InventoryTag.java =====
public class InventoryTag {
private int quantityRemaining;
public InventoryTag(){
quantityRemaining =0;
}
public int getQuantityRemaining(){
return quantityRemaining;
}
public void addInventory(int numItems){
if (numItems >10){
quantityRemaining = quantityRemaining + numItems;
}
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!