Recently I was adding some tests to a module I have written and I thought that in this particular instance it would be good if the module being tested was aware of it being tested, so it could slightly change its behaviour.
Is there an easy way to check if a module is run by a test script? I can of course write a semaphore file and check that, but that seems overkill, not to mention the overhead of checking for the file every-time.
CountZero
A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James
In reply to How to make a module aware it is being tested? by CountZero
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |