Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 244161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:58:54+00:00 2026-05-11T20:58:54+00:00

I am trying to practice TDD. My understanding is that TDD should go like

  • 0

I am trying to practice TDD.

My understanding is that TDD should go like this

  1. Write a test list for the interface/class I am going to develop.
  2. Start with the easiest not implemented test from my test list.
  3. Write the test, no implementation code yet.
  4. Write the interface of the class to make the code compile.
  5. Run the test resulting in one failing test.
  6. Write the implementation making the test pass.
  7. Refactor the mess I’ve made.
  8. Goto 2.

The problem I have is when writing the implementation or doing the refactoring. I often come to the conclusion that the implementation I just wrote should be delegated to another class.

What should a true TDD’r do at this point?

  1. Leave the existing test list alone for a while and create a new one for the newly discovered class (the same problem can manifest itself when implementing the new class offcourse)
  2. Go the Interaction Based way of testing and Mock the new class, continue with the testcases of the class you are working on and come back later to create a correct implementation of the mocked class.
  3. This situation should not present itself. I probably have not thought out my initial design well enough. (but wouldn’t that defeat one of the purposes of TDD?!).

I’d love to know how other people handle these situations.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:58:54+00:00Added an answer on May 11, 2026 at 8:58 pm

    Don’t look for a one-to-one relationship between your tests and your classes. If you decide to introduce a new class, let that be a refactoring supported by the original test, and add tests in the appropriate place (where that is depends on the specific case) when you want to add functionality (or to test eventualities you need to cover that you didn’t test for yet).

    I would add that the main success in TDD is to get into the rhythm of red-green-refactor. When you feel the benefit of that rhythm, you have started to “get” it. That isn’t to say you will find it worthwhile in all cases, but until you feel that rhythm you haven’t gotten to what its advocates like about it.

    And there is usually (especially in architecturally complicated applications, like n-tier applications) some amount of up-front design. Nothing sketched in stone, but enough to give the units a place to go. Of course the architecture may evolve in an agile methodology, but a general idea of the landscape needs to be there if there are multiple layers to the architecture.

    EDIT: (In response to the comment). Should the new class get tested in its own right? Not necessarily. It depends if the class develops an importance of its own. When you are unit testing, you are testing a piece of functionality. It isn’t an integration test just because there are two classes involved. It becomes an integration test when two units start interacting. The boundary I typically think of is if I have to set up significant state in group-of-classes A to interact with group-of-classes B, and especially if group-of-classes A calls group-of-classes B and what I am interested in testing is how B reacted to A, then I’m looking at an integration test.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to learn LINQ by practice. This seems like a situation where I
I am trying to use TDD for my coding practice. I would like to
Recently I was trying some practice programs in python and I came across this
Trying to get the grips of best URI practice in RESTfulness... Let's say that
I'm trying to practice myself with custom class loaders, and I've some questions. Is
Ok so I thought this would be a snap, trying to practice Scala's collection
Currently trying to come up with a best practice for a ZF site that
I'm trying to practice some CSS/HTML, and I am listing what should be done
I'm trying to build an app (for practice) that uses CoreData and different view
I'm using Oracle apex and am trying to practice with automatic emails. Ideally, this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.