In this thread, Brian (the only answerer) says "Your code should be written in such a fashion that it is testing-agnostic"
The single comment says "Your code should definitely not branch on a global "am I being tested flag".".
But neither gives reasons, and I would really like to hear some rational thoughts on the matter. It would be immensely easy (particularly given the fact that a lot of tests have package-private access to the app classes) to reach into a given app class and set a boolean to say "this is a test, not a run".
All sorts of things which I find myself jumping through hoops (injected mocked private fields, etc.) to achieve could become easier to accomplish.
It's also obvious that if you took this too far it could be disastrous... but as one tool among many in the software testing armoury why does the concept meet with such opprobrium?
Aucun commentaire:
Enregistrer un commentaire