TDD stands for Test-Driven Development, or Test-Driven Design. It is the practice of writing a unit test before writing code to satisfy it, in what is known as the Red-Green-Refactor cycle.

learn more… | top users | synonyms (2)

71
votes
13answers
7k views

When is it appropriate to not unit test?

I work in a small company as a solo developer. I'm the only developer at the company in fact. I have several (relatively) large projects I've written and maintain regularly, and none of them have ...
66
votes
16answers
9k views

When is unit testing inappropriate or unnecessary? [duplicate]

It seems to be generally assumed (on Stack Overflow at least) that there should always be unit tests, and they should be kept up to date. But I suspect the programmers making these assertions ...
9
votes
5answers
952 views

Do I need unit test if I already have integration test?

If I already have integration test for my program, and they all passed, then I have a good feel that it will work. Then what are the reasons to write/add unit tests? Since I already have to write ...
12
votes
2answers
570 views

Software Testing Techniques [closed]

What kinds of software testing do you know? I've heard about Test-Driven Development, Unit tests etc, but can't understand their importance and difference. For example, why are we using regression ...
5
votes
1answer
629 views

Is wrapping a third party code the only solution to unit test its consumers?

I'm doing unit testing and in one of my classes I need to send a mail from one of the methods, so using constructor injection I inject an instance of Zend_Mail class which is in Zend framework. Now ...
29
votes
5answers
5k views

What are the disadvantages of test-first programming?

It's all the rage nowadays. "Everyone" recommends it. That in and of itself makes me suspicious. What are some disadvantages you have found when doing test-first (test-driven) development? I'm ...
29
votes
5answers
2k views

How do you convince management to “invest” in unit tests?

How did you convince your manager to let you unit test? By "use", I mean being allowed to develop, check-in to source control and maintain the unit tests over time, etc. Typical management ...
121
votes
6answers
52k views

What is the difference between BDD and TDD?

I have been learning writing test cases for BDD using specflow. If I write comprehensive tests with BDD is it necessary to write TDD test separately? Is it necessary to write test cases for both TDD ...
34
votes
10answers
4k views

Is unit testing or test-driven development worthwhile?

My team at work is moving to Scrum and other teams are starting to do test-driven development using unit tests and user acceptance tests. I like the UATs, but I'm not sold on unit testing for ...
25
votes
7answers
8k views

Difference Between Unit Testing and Test Driven Development

From reading the descriptions, I understand that in TDD tests are done prior to writing the function and in Unit Testing, its done afterwards. Is this the main difference, or the two terms can't even ...
26
votes
5answers
3k views

Why is it often said that the test cases need to be made before we start coding? [duplicate]

Why is it often said that the test cases need to be made before we start coding? What are its pros and what the cons if we don't listen to this advice? Moreover, does that advice refer to black box ...
11
votes
5answers
2k views

What is a normal “functional lines of code” to “test lines of code” ratio?

I'm pretty new to TDD approach and my first experiments say that writing 1 line of functional code means writing about 2-3 lines of testing code. So, in case I'm going to write 1000 LOC, the whole ...
13
votes
6answers
1k views

Looking for Case Studies of How TDD Improved Quality and/or Speed of Development [closed]

At my company I am trying to make a case for why we should be doing TDD. Currently most developers just do whatever they can to get the project done, then go add unit tests after the fact in order to ...
95
votes
10answers
4k views

TDD vs. Productivity

In my current project (a game, in C++), I decided that I would use Test Driven Development 100% during development. In terms of code quality, this has been great. My code has never been so well ...
69
votes
16answers
7k views

TDD negative experience [closed]

What is a negative side of your TDD experience? Do you find baby steps (the simplest fix to make test green) annoying and useless? Do you find no-value tests (when test has sense initially but in ...
67
votes
19answers
7k views

Why does TDD work?

Test-driven development (TDD) is big these days. I often see it recommended as a solution for a wide range of problems here in Programmers SE and other venues. I wonder why it works. From an ...
22
votes
8answers
2k views

Are “TDD Tests” different to Unit Tests? [duplicate]

I read Stephen Walther's article about Test Driven Development (TDD) and unit testing. I think it was an excellent article. The author makes a distinction between what he calls "TDD Tests" and unit ...
29
votes
4answers
1k views

Are there areas where TDD provides a high ROI and other areas where the ROI is so low that it is not worth following? [closed]

Test driven development. I get it, like it. But writing tests does require overhead. So should TDD be used universally throughout the code base, or are there areas where TDD provides a high ROI and ...
10
votes
4answers
873 views

When should I use mock objects?

I've read a lot of things about TDD but I still have doubts. For example, I have these class diagrams: It's a simple example, just to learn about TDD and mock objects. Which test should I write ...
18
votes
3answers
2k views

Does TDD lead to the good design? [duplicate]

I'm in transition from "writing unit tests" state to TDD. I saw as Johannes Brodwall creates quite acceptable design from avoiding any of architecture phase before. I'll ask him soon if it was real ...
6
votes
2answers
493 views

Unit test SHA256 wrapper queries

I have the following SHA256 wrapper. public static string SHA256(string plainText) { StringBuilder sb = new StringBuilder(); SHA256CryptoServiceProvider provider = new ...
54
votes
12answers
5k views

New to TDD. Should I avoid private methods now?

I'm just now learning TDD. It's my understanding that private methods are untestable and shouldn't be worried about because the public API will provide enough information for verifying an object's ...
49
votes
16answers
3k views

Why not write all tests at once when doing TDD?

The Red - Green - Refactor cycle for TDD is well established and accepted. We write one failing unit test and make it pass as simply as possible. What are the benefits to this approach over writing ...
29
votes
7answers
1k views

Unit testing newbie team needs to unit test

I'm working with a new team that has historically not done ANY unit testing. My goal is for the team to eventually employ TDD (Test Driven Development) as their natural process. But since TDD is ...
28
votes
5answers
2k views

Test driven development - convince me! [closed]

I know some people are massive proponents of test driven development. I have used unit tests in the past, but only to test operations that can be tested easily or which I believe will quite possibly ...
15
votes
8answers
902 views

What are good unit tests to cover the use case of rolling a die?

I'm trying to get to grips with unit testing. Say we have a die which can has a default number of sides equal to 6 (but can be 4, 5 sided etc.): import random class Die(): def __init__(self, ...
11
votes
4answers
2k views

Should each unit test be able to be run independently of other tests?

Say you have tests for two methods of a class. The first method gathers data from another tier and puts it into some sort of storage independent of the runtime (such as a SQL table), so all of the ...
9
votes
5answers
1k views

The Relative Cost Efficiency of (Acceptance) Test Driven Development

I would like to know what the overall impact of resource planning on a software project is, where the requirements and design of the project are driven by automated acceptance tests and unit tests, in ...
20
votes
7answers
803 views

Should I have unit tests for known defects?

If my code contains a known defect which should be fixed, but isn't yet, and won't be fixed for the current release, and might not be fixed in the forseeable future, should there be a failing unit ...
17
votes
11answers
1k views

At what point would you drop some of your principles of software development for the sake of more money?

I'd like to throw this question out there to interestingly see where the medium is. I'm going to admit that in my last 12 months, I picked up TDD and a lot of the Agile values in software ...
15
votes
5answers
1k views

How granular should TDD tests be?

During TDD training based on medical software case we are implementing the following story: "When user presses Save button, system should add patient, add device and add device data records". The ...
26
votes
11answers
2k views

Writing the minimum code to pass a unit test - without cheating!

When doing TDD and writing a unit test, how does one resist the urge to "cheat" when writing the first iteration of "implementation" code that you're testing? For example: Let's I need to calculate ...
20
votes
8answers
1k views

What are the disadvantages of writing code before writing unit tests?

I have always seen the recommendation that we should first write unit tests and then start writing code. But I feel that going the other way is much more comfortable (for me) - write code and then the ...
18
votes
6answers
815 views

Does adding unit tests make sense for well-known legacy code?

I'm talking about unit tests in the TDD sense. (Not automated "integration", or what you like to call it tests.) Legacy code as in: (C++) code without tests. (see: Michael Feathers' Working ...
11
votes
10answers
806 views

How to convince teammates to use TDD

I am the only person on my team that use TDD. How do I make them to use it? I am annoyed that when I pull, someone's code will break my tests and I am the one who has to fix them. Will using github, ...
11
votes
2answers
931 views

Relation between BDD and TDD

What is the relation of BDD and TDD? From what I understood BDD adds two main things over TDD: tests naming (ensure/should) and acceptance tests. Should I follow TDD during development by BDD? If ...
9
votes
6answers
541 views

test driven development - Who should write the tests?

Originally, it is the duty of the developer to write the test, but I noticed that in many cases/e-mature developers those cases are not giving even 80% coverage. How about I have a QA person dedicated ...
6
votes
4answers
619 views

How do asserts and other error avoidance checks fit into TDD?

http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd You are not allowed to write any production code unless it is to make a failing unit test pass. So where do asserts fit into this? If ...
9
votes
5answers
1k views

If TDD is about design why do I need it?

TDD gurus more and more tell us that TDD is not about tests, it is about design. So I know some developers who create really great design without TDD. Should they practice TDD then?
2
votes
2answers
224 views

Moving legacy application to a testable framework?

We have a web application which contains a web service with over 50 methods. The application is currently installed at a number of sites and is currently being maintained by one developer. The ...
148
votes
16answers
11k views

Why does automated testing keep failing in my company?

We have tried to introduce developer automated testing several times at my company. Our QA team uses Selenium to automate UI tests, but I always wanted to introduce unit tests and integration tests. ...
344
votes
12answers
11k views

Should I intentionally break the build when a bug is found in production?

It seems reasonable to me that if a serious bug is found in production by end-users, a failing unit test should be added to cover that bug, thus intentionally breaking the build until the bug is ...
31
votes
7answers
2k views

Is it sufficient to use acceptance and integration tests instead of unit test?

Short introduction to this question. I have used now TDD and lately BDD for over one year now. I use techniques like mocking to make writing my tests more efficiently. Lately I have started a ...
46
votes
11answers
3k views

I don't understand how TDD helps me get a good design if I need a design to start testing it

I'm trying to wrap my head around TDD, specifically the development part. I've looked at some books, but the ones I found mainly tackle the testing part - the History of NUnit, why testing is good, ...
37
votes
11answers
10k views

What are the disadvantages of automated testing?

There are a number of questions on this site that give plenty of information about the benefits that can be gained from automated testing. But I didn't see anything that represented the other side of ...
36
votes
14answers
2k views

If you had two projects with the same specification and only one was developed using TDD how could you tell?

I was asked this question in an interview and it has been bugging me ever since. You have two projects, both with the same specification but only one of these projects was developed using Test ...
30
votes
6answers
3k views

How should you TDD a Yahtzee game?

Let's say you're writing a Yahtzee game TDD style. You want to test the part of the code that determines whether or not a set of five die rolls is a full house. As far as I know, when doing TDD, you ...
36
votes
6answers
6k views

Good example of complex code using TDD [closed]

What would be a good example of the use of TDD in large, real-life, complex, projects? All the examples I've seen so far are toy projects for the purpose of a book or a paper... Can you name an ...
32
votes
2answers
2k views

How should C++ Unit Test code be organized for maximum Unit Test efficiency?

This question is not about Unit Testing Frameworks. This question is not about writing Unit Tests. This question is about where to put the UT code written and how/when/where to compile and run it. ...
43
votes
6answers
6k views

How to deal with static utility classes when designing for testability

We are trying to design our system to be testable and in most parts developed using TDD. Currently we are trying to solve the following problem: In various places it is necessary for us to use static ...