I want to write unit test case for bestElement() method using mockito. ClassA and ClassB are in same package. I want to test when the array list is empty and when the array list is not empty. I am new in unit testing. Please guide me how to write unit test for this method for both the cases. Also mention if any other information is required. THANKS!
public class ClassA{
private final ArrayList<ClassB> array = new ArrayList<>();
public ClassB bestElement() {
if (array.isEmpty()) {
return null;
}
ClassB first = array.get(0);
array.remove(0);
return first;
}
Aucun commentaire:
Enregistrer un commentaire