Accueil > Non classé > Thoughts and questions on Pragmatic Unit Testing

Thoughts and questions on Pragmatic Unit Testing

2 points stroke me when reading this « Pragmatic Unit Testing » book :

– in order to easily test some class, they suggest to open the required methods by making them protected. I had first to check that protected included package readability (it does) but still I think it’s going a bit too far : if the method was supposed to be private, package private is the nearest visibility which would fit. I would only make it protected if I intent to override it. Do I miss something ?

– the last paragraph is called « Testing invalid parameters », and speaks of where to test the validity of the parameters. Their answer is « we find the easiest rule to adopt is the ‘keep the barbarians out at the gate » approach’, meaning internal components can trust the data they get. At work, we do it differently : every non private method has to check for the validity of its input (for which we have a dedicated assertion lib.). Would you suggest otherwise ?

++

Publicités
Étiquettes : , , ,
  1. Uwe Schaefer
    septembre 7, 2009 à 6:34

    every non private method has to check for the validity of its input (for which we have a dedicated assertion lib.). Would you suggest otherwise ?

    No 🙂

    the point is, that the gates are moving. 😉

  2. Joseph Pachod
    septembre 12, 2009 à 9:30

    Took me some time to figure out the exact meaning of this sentence, but now I get it and yes, you’re darn right 🙂 Who knows which part of the code will be public in the future ?

  1. No trackbacks yet.

Laisser un commentaire

Entrez vos coordonnées ci-dessous ou cliquez sur une icône pour vous connecter:

Logo WordPress.com

Vous commentez à l'aide de votre compte WordPress.com. Déconnexion / Changer )

Image Twitter

Vous commentez à l'aide de votre compte Twitter. Déconnexion / Changer )

Photo Facebook

Vous commentez à l'aide de votre compte Facebook. Déconnexion / Changer )

Photo Google+

Vous commentez à l'aide de votre compte Google+. Déconnexion / Changer )

Connexion à %s

%d blogueurs aiment cette page :