jeudi 3 septembre 2015

is JDK assert necessary to use?

I read a book says “it makes sense to use assert for testing internal code. For instance:

private String welcome(String name) {
  assert name!=null && !name.isEmpty() : "name must be specified";
  return "Hello, " + name;
}

” then the book introduces unite test.I wonder is it necessary to use assert even having unite test? thank you.

Aucun commentaire:

Enregistrer un commentaire