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

  • Home
  • SEARCH
  • 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 328229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T09:28:32+00:00 2026-05-12T09:28:32+00:00

A few weeks ago I started my first project with TDD. Up to now,

  • 0

A few weeks ago I started my first project with TDD. Up to now, I have only read one book about it.

My main concern: How to write tests for complex methods/classes. I wrote a class that calculates a binomial distribution. Thus, a method of this class takes n, k, and p as input, and calculates the resp. probability. (In fact it does a bit more, that’s why I had to write it myself, but let’s stick to this description of the class, for ease of the argument.)

What I did to test this method is: copying some tables with different n I found in the web into my code, picking randomly an entry in this table, feeded the resp. values for n, k, and p into my function, and looked whether the result was near the value in the table. I repeat this a number of times for every table.

This all works well now, but after writing the test, I had to tank for a few hours to really code the functionality. From reading the book, I had the impression that I should not code longer than a few minutes, until the test shows green again. What did I do wrong here? Of course I have broken this task down in a lot of methods, but they are all private.

A related question: Was it a bad idea to pick randomly numbers from the table? In case of an error, I will display the random-seed used by this run, so that I can reproduce the bug.

  • 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-12T09:28:32+00:00Added an answer on May 12, 2026 at 9:28 am

    “I had the impression that I should not code longer than a few minutes, until the test shows green again. What did I do wrong here?”

    Westphal is correct up to a point.

    Some functionality starts simple and can be tested simply and coded simply.

    Some functionality does not start out simple. Simple is hard to achieve. EWD says that simplicity is not valued because it is so difficult to achieve.

    If your function body is hard to write, it isn’t simple. This means you have to work much harder to reduce it to something simple.

    After you eventually achieve simplicity, you, too, can write a book showing how simple it is.

    Until you achieve simplicity, it will take a long time to write things.

    “Was it a bad idea to pick randomly numbers from the table?”

    Yes. If you have sample data, run your test against all the sample data. Use a loop or something, and test everything you can possibly test.

    Don’t select one row — randomly or otherwise, select all rows.

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

Sidebar

Related Questions

I started working with C# a few weeks ago and I'm now in a
I started a github project a few weeks ago. I was able to push
Bit of background, I'm a total lisp noob, only started a few weeks ago,
I have downloaded Privoxy few weeks ago and for the fun I was curious
Few weeks ago I started using VS 2008 (Professional) with Windows 7 (Enterprise). When
A few weeks ago I started making a change in my SVN repository's trunk
a few weeks ago I started to use xsd.exe for create classes for serialization/deserialization
I started learning Rails only a few days ago, but in the mean time
I've started learning Objective-C a few weeks ago and I still don't understand how
A few weeks ago i asked a question about a multilanguage site (see Multilanguage

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.