Frage

If I had the following code

public static <T> int count(List<T> list, T elem) {
  int count = 0; // the result
  for (int i=0; i < list.size(); i++) {
  if (list.get(i).equals(elem))
  count++;
  }
 return count;
}

Lets say I need to run a black box test,

Like so,

Input

[null], null Output should be 0

Firstly, is this a worthwhile test case? ( for black box testing)

If not,

Then I ask, are null values worth while tests for black box testing in any case?(in general)

Thanks

War es hilfreich?

Lösung

How code reacts to null inputs is something that should be documented and tested, yes.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top