Loading ...
Sorry, an error occurred while loading the content.

Testing and Refactoring (was: Re: [hackers-il] The Philosophy of Automated Tests)

Expand Messages
  • Omer Zak
    ... [... snipped ...] ... I would say - write tests before and during refactoring. Do the refactoring at several steps, such that at the end of each step, the
    Message 1 of 4 , Jan 28, 2005
    • 0 Attachment
      On Fri, 28 Jan 2005, Shlomi Fish wrote:

      > On Saturday 15 January 2005 11:09, Adi Stav wrote:
      > > Hi Shlomi,
      [... snipped ...]
      > > So refactoring doesn't really change
      > > things, unless it creates a new code path, requiring a modification in
      > > the tests.
      > >
      >
      > Can refactoring actually create a new code path? As you may know, refactoring
      > is improving the internal design of the program without modifying its
      > external behaviour.
      >
      > Do you write the test to test this new code path before or after the
      > refactoring?

      I would say - write tests before and during refactoring.
      Do the refactoring at several steps, such that at the end of each step,
      the piece of software has the same external behavior.
      Run the tests on the original software and on the refactored software
      at each step.
      Add new tests as necessary to exercise cases which you did not think of
      previously.

      By the way, I cannot think of a case in which refactoring would add an
      extra code path. At least, not in languages having adequate expressive
      power (such as Python).
      --- Omer
      My opinions, as expressed in this E-mail message, are mine alone.
      They do not represent the official policy of any organization with which
      I may be affiliated in any way.
      WARNING TO SPAMMERS: at http://www.zak.co.il/spamwarning.html
    Your message has been successfully submitted and would be delivered to recipients shortly.