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

Re: [XP] Correctly fragmenting code for testing without artifical structure

Expand Messages
  • J. B. Rainsberger
    ... Why do so many places need to know about I/O? Isn t it all string manipulation until the exact moment you save? Then isn t it just write these lines to
    Message 1 of 3 , Oct 19, 2007
    • 0 Attachment
      Wilson, Michael wrote:
      >
      >
      > I'm having a baby noob TDD testability problem.
      >
      > I'm working on a proof of concept java application that saves a bunch of
      > data as csv. So I have all the flexibility I want (and then some ;)
      >
      > The code that does the translation between native objects and the
      > persistence format is nice and granular, easy to test and robust.
      >
      > But bringing the top level save/load methods under test proving very
      > hard to test due to two things:
      >
      > - the reliance on the OS services of file management very deep in the
      > stack
      > - the transparency of the mechanism to the top level. (i.e. I'm trying
      > to bring a method under test that has a signature somewhat like "void
      > save(Contacts c)".
      >
      > So what's the right approach to restructure this?
      >
      > Creating a mocked up BufferedReader / BufferedWriter and passing that
      > around would easily double of not triple the size of the code, which is
      > precisely the thing I'm trying to avoid doing. I don't want some
      > significant portion of the app to be bound up as test scaffolding.

      Why do so many places need to know about I/O? Isn't it all string
      manipulation until the exact moment you save? Then isn't it just "write
      these lines to that file"?

      Without more detail, I don't understand how this could be a problem.
      --
      J. B. (Joe) Rainsberger :: http://www.jbrains.ca
      Your guide to software craftsmanship
      JUnit Recipes: Practical Methods for Programmer Testing
      2005 Gordon Pask Award for contribution Agile Software Practice
    Your message has been successfully submitted and would be delivered to recipients shortly.