Question: I am really confused by this code. The instructor posted as optional but I really would like to know how to get it done. The

I am really confused by this code. The instructor posted as optional but I really would like to know how to get it done.

The question of the problem is how to "add unit test for addInventory"

Prompt:

"Write a unit test for addInventory(). 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."

This is the code:

// ===== 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; } return; } } // ===== end =====

// ===== Code from file CallInventoryTag.java ===== public class CallInventoryTag { public static void main (String [] args) { InventoryTag redSweater = new InventoryTag(); int sweaterShipment = 0; int sweaterInventoryBefore = 0;

sweaterInventoryBefore = redSweater.getQuantityRemaining(); sweaterShipment = 25;

System.out.println("Beginning tests.");

// FIXME add unit test for addInventory

/* Your solution goes here */

System.out.println("Tests complete.");

return; } } // ===== end =====

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 Databases Questions!