Pergunta

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

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top