Domanda

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

È stato utile?

Soluzione

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

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top