JUnit testing a class on Netbeans
Could someone JUnit test the code ive pasted below on NetBeans? Im not quite sure what to do once ive created the actual test. If someone could help me it would be greatly appreciated as i could learn from yours for future JUnit testing.


    package prog3;     
    
    import java.util.ArrayList;     import java.util.Iterator;
    
    public class MedicineClass
    {
        private String MedicineName;
        private int MedicineRegNum;
        private ArrayList RelatedMedicine;
    
        public MedicineClass(String newMedicineName, int newMedicineRegNum)
        {
            newMedicineName = MedicineName;
            newMedicineRegNum = MedicineRegNum;
            RelatedMedicine = new ArrayList();
        }
    
        public void setMedicine(String newMedicineName)
        {
            newMedicineName = MedicineName;
        }
    
        public String getMedicineNameAndNum()
        {
            return "Medicine Registration Number: " + MedicineRegNum + "Medicine Name: " + MedicineName;
        }
    
        public void Medicine(Medicine Drug)
        {
            RelatedMedicine.add(Drug);
        }
    
        public void addMedicine(String newMedicineName, int newMedicineRegNum)
        {
            Medicine temp = new Medicine(newMedicineName, newMedicineRegNum);
            RelatedMedicine.add(temp);
        }
    
        public void listAllMedicines()
        {
            StringBuilder sb = new StringBuilder();
            Iterator lst = RelatedMedicine.iterator();
            while (lst.hasNext())
            {
                Medicine temp = (Medicine)lst.next();
                sb.append(temp.getNameandRegNum());
                sb.append("\n");
    
            }
            System.out.println(sb.toString());
        }
    
    }


JUnit testing a class on Netbeans
===

Could someone JUnit test the code ive pasted below on NetBeans? Im not quite sure what to do once ive created the actual test. If someone could help me it would be greatly appreciated as i could learn from yours for future JUnit testing.


    package prog3;     
    
    import java.util.ArrayList;     import java.util.Iterator;
    
    public class MedicineClass
    {
        private String MedicineName;
        private int MedicineRegNum;
        private ArrayList RelatedMedicine;
    
        public MedicineClass(String newMedicineName, int newMedicineRegNum)
        {
            newMedicineName = MedicineName;
            newMedicineRegNum = MedicineRegNum;
            RelatedMedicine = new ArrayList();
        }
    
        public void setMedicine(String newMedicineName)
        {
            newMedicineName = MedicineName;
        }
    
        public String getMedicineNameAndNum()
        {
            return "Medicine Registration Number: " + MedicineRegNum + "Medicine Name: " + MedicineName;
        }
    
        public void Medicine(Medicine Drug)
        {
            RelatedMedicine.add(Drug);
        }
    
        public void addMedicine(String newMedicineName, int newMedicineRegNum)
        {
            Medicine temp = new Medicine(newMedicineName, newMedicineRegNum);
            RelatedMedicine.add(temp);
        }
    
        public void listAllMedicines()
        {
            StringBuilder sb = new StringBuilder();
            Iterator lst = RelatedMedicine.iterator();
            while (lst.hasNext())
            {
                Medicine temp = (Medicine)lst.next();
                sb.append(temp.getNameandRegNum());
                sb.append("\n");
    
            }
            System.out.println(sb.toString());
        }
    
    }

