I am trying to undarstand if I am writing unit test in the write way. I have a hashmap where I store my customer register. I am trying to write a unit test for my createCustomer metod. Can someone give me pointers if I am in the right direction?
void addCustomer () {
System.out.println ();
String customerName = getString ("Enter Customer Name with cappital letar: ");
String customerAddress = getString ("Enter Customer Address with cappital letar: ");
int customerPhone = getInt ("Enter Customer phone:");
int customerID = checkID ();
Customer customer = new Customer (customerName, customerAddress, customerID, customerPhone);
customerList.put (customerID, customer);
System.out.println ("Customer Added");
}
@Test
public void addCustomerTest () {
HashMap<Integer,Customer> customerList = new HashMap<> ();
String customerName = "Anna";
String customerAddress = "London";
int customerPhone = 1010101;
int customerID = 1000;
Customer customer = new Customer (customerName, customerAddress, customerID, customerPhone);
customerList.put (customerID, customer);
assertTrue(customerList.containsKey(customerID) && customerList.get(customerID) != null);
}