jeudi 5 mars 2015

How can we test if an array returns with different length?

I want to test a method with signature int[] myMethod(int[] array, int removedElement) as argument. The method should remove the element if the element in in the array. As a result, the method may be able to return int[] with array.length - 1.


assertArrayEquals() does not confirm if the returned array has different length.


assertNotEquals() is not appropriate because the method may be removed wrongly more than one element.


How can I test this method?


Aucun commentaire:

Enregistrer un commentaire