- Write A Unit Test For Addinventory Which Has An Error Call Redsweater Addinventory With Parameter Sweatershipment P 1 (33.44 KiB) Viewed 24 times
Write a unit test for addinventory(), which has an error. Call redSweater addinventory with parameter sweaterShipment. P
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
Write a unit test for addinventory(), which has an error. Call redSweater addinventory with parameter sweaterShipment. P
Write a unit test for addinventory(), which has an error. Call redSweater addinventory with parameter sweaterShipment. Print the shown error if the subsequent quantity is incorrect. Sample output for failed unit test given initial quantity is 10 and sweaterShipment is 50. 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; } // end ----- // Code from file CallinventoryTag.java import java.util.Scanner; public class CallInventoryTag public static void main(String [] args) { Scanner scnr- new Scanner (System.in); InventoryTag redSweater new InventoryTag(); int sweaterShipment; int sweaterInventoryBefore; sweater InventoryBefore redSweater.getQuantityRemaining(); sweaterShipment scnr.nextInt (); System.out.println("Beginning tests."); // FIXME add unit test for addInventory /* Your solution goes here */ System.out.println("Tests complete.");