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

118541Re: TDD and C++

Expand Messages
  • Anthony Williams
    Apr 3, 2006
    • 0 Attachment
      Alex Pukinskis <Alex.Pukinskis@...> writes:

      > Anyone with some experience doing TDD in C++ willing to talk about their
      > experiences? Particularly in telecom, networking, or embedded applications?

      I do most of my development in C++, doing TDD, and most of the applications I
      work on have some networking component.

      As others have mentioned, the first step is to find/build a unit testing
      framework. I use a homegrown one for most projects, but I also use Boost.Test
      for others. I like my homegrown one, because it uses the constructor of the
      test-case class for setup, and the destructor for tear-down. YMMV.

      Once you're up and running, again as others have mentioned, pay close
      attention to build times. Excessive build times can really hurt the TDD cycle,
      as you have to do something else whilst it's building, otherwise you get
      bored. The key to getting build times down is to work hard on reducing
      dependencies. Persistent refactoring also helps --- if there's less code,
      because there's less duplication, then it takes less time to compile it.

      For network apps, test the actual network comms once --- to verify that sent
      data does get sent, and data is received correctly. Once that works, then do
      everything else one layer removed, working to an interface, with a dummy
      implementation in the test. That way you can avoid the overhead inherent in
      network comms, not just in time, but also in test complexity.

      Of course, as with any development, you want to use good C++ coding
      conventions and idioms, but the real difference that TDD makes to my C++ code
      is the extensive use of abstract classes as interfaces.

      Anthony Williams
      Software Developer
      Just Software Solutions Ltd
    • Show all 27 messages in this topic