in reply to Re: How to make a module aware it is being tested?
in thread How to make a module aware it is being tested?

I agree with you that in general changing the behaviour of a module when it is being tested is not a good idea, but in this case I wish the module to add a distinguishing mark to the primary key field of a database record when it is being tested so the records inserted by the test cannot be mistaken for real records. The module will have to work with an active / life database and the records to be inserted are parsed from real life example files which I cannot change.

Your idea of flagging to the module it is being tested is good, but it means I have to rewrite all my tests to add that flag and in the future may not forget to use that flag.

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

  • Comment on Re^2: How to make a module aware it is being tested?

Replies are listed 'Best First'.
Re^3: How to make a module aware it is being tested?
by Anonymous Monk on Nov 02, 2007 at 03:58 UTC
    The module will have to work with an active / life database and the records to be inserted are parsed from real life example files which I cannot change.
    Setting up a database for testing by copying a few records from the live database sounds like a better idea.
      Ultimately that will indeed be the best idea, but it means I have to redo all my tests to set-up a SQLite database for testing purposes. I have put it on my TODO list for version 2.

      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