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)

14
votes
6answers
918 views

TDD: What happens before the first unit test?

I mostly understand the theory of TDD, but I can't figure out how to get started. I sit down to write a unit test for a personal project and realize . . . I have no idea what I am testing. What ...
12
votes
7answers
580 views

TDD with limited resources

I work in a large company, but on a just two man team developing desktop LOB applications. I have been researching TDD for quite a while now, and although it is easy to realize its benefits for ...
10
votes
4answers
854 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 ...
21
votes
5answers
2k views

Do unit tests sometimes break encapsulation? [duplicate]

I very often hear the following: "If you want to test private methods, you'd better put that in another class and expose it." While sometimes that's the case and we have a hiding concept inside our ...
13
votes
3answers
6k views

Good unit test examples for embedded C developers [closed]

I'm going to be giving a talk to my department next week about unit testing and test-driven development. As part of this, I'm going to show some real-world examples from some code I've written ...
16
votes
6answers
2k views

how much time do you spend on Unit testing?

In a company I used to work for, executives insisted that the code coverage with unit tests must be 99% or more. This resulted in writing more tests than code. It took us literally 3 days to write ...
15
votes
3answers
2k views

Real-world examples of apps written with TDD and good test coverage? [closed]

Are there any open source applications that are developed using test driven development that serve as models of how good unit testing should work? I'd prefer to see examples in C# and .NET. (Note ...
14
votes
5answers
1k views

Whats the real overhead of TDD once the entire team is used to it?

What percentage of time is saved and costed doing TDD. I assume this percentage of cost and reward changes during a projects life-cycle. I'd imagine the initial phase has a lot more cost but little ...
9
votes
5answers
1k views

How do you keep your unit tests working when refactoring?

In another question, it was revealed that one of the pains with TDD is keeping the testing suite in sync with the codebase during and after refactoring. Now, I'm a big fan of refactoring. I'm not ...
8
votes
7answers
3k views

How do I do TDD on embedded devices?

I'm not new to programming and I've even worked with some low level C and ASM on AVR, but I really can't get my head around a larger-scale embedded C project. Being degenerated by the Ruby's ...
5
votes
3answers
3k views

How to test the data access layer?

I have a DAO method that utilizes Spring for JDBC access. It calculates a seller's success rate of selling an item. Here is the code: public BigDecimal getSellingSuccessRate(long seller_id) { ...
10
votes
3answers
209 views

How do you efficiently keep your tests working as you redesign?

A well-tested codebase has a number of examples, but testing certain aspects of the system results in a codebase that is resistant to some types of change. An example is testing for specific ...
6
votes
4answers
1k views

End-to-end tests versus unit tests, should tests be decoupled?

At our company we typically make sure that we write an end-to-end test for our websites/web apps. That means we access a URL, fill in a form, submit the form to another URL and check the results of ...
5
votes
3answers
668 views

In TDD, if I write a test case that passes without modifying production code, what does that mean?

These are Robert C. Martin's rules for TDD: You are not allowed to write any production code unless it is to make a failing unit test pass. You are not allowed to write any more of a unit test than ...
11
votes
3answers
581 views

What to do when your colleagues don't value code maintainability [duplicate]

I've been working in the same software development department for a few years now. In that time, the average stay of a developer has been 6-9 months. A handful have been around for over 2 years, but ...
11
votes
5answers
757 views

How to do TDD for something with many permutations?

When creating a system like an AI, which can take many different paths very quickly, or really any algorithm that has several different inputs, the possible result set can contain a large number of ...
9
votes
6answers
2k views

Single or multiple files for unit testing a single class?

In researching unit testing best practices to help put together guidelines for my organization, I've run into the question of whether it is better or useful to separate test fixtures (test classes) or ...
7
votes
5answers
616 views

TDD: Mocking out tightly coupled objects

Sometimes objects just need to be tightly coupled. For example, a CsvFile class will probably need to work tightly with the CsvRecord class (or ICsvRecord interface). However from what I learned in ...
4
votes
2answers
307 views

Can I start with a passing unit test?

Uncle Bob's rules for TDD are specified here. You are not allowed to write any production code unless it is to make a failing unit test pass. You are not allowed to write any more of a unit test ...
18
votes
4answers
757 views

Should we always unit test bugs when correcting them?

When correcting bugs, it is encouraged where I work to first write a test that fails with the given bug, and then to fix the code until the test passes. This follows TDD practices, and is supposed to ...
5
votes
5answers
325 views

An alternative to requiring red in TDD: reverting code change?

According to this answer to this question, a good reason for always starting with a failing test ("Red") is to make sure that the test is working and that the code that will be written is what makes ...
3
votes
2answers
941 views

How much extra time is needed to add unit test in a development task?

My team is considering moving to test-driven development. Currently we have almost no unit testing, we have been only relying on the user acceptance test, and developer's own manual test. Not everyone ...
2
votes
5answers
423 views

DRY code, DRY tests?

At some point I had to create some class "Class1" and that class needs a method "method". So I have the following: Class1MethodTest: A total of N tests that check the behavior of Class1.method Class1 ...
2
votes
3answers
555 views

TDD, BDD or both? [duplicate]

I'm a little bit confused about BDD. I'm doing TDD currently. My question is whether BDD is complementary to TDD or it's a whole new thing and my team should do both TDD and BDD? Or is it enough to ...
1
vote
2answers
376 views

Testing ASP.NET .aspx and .ascx code behind files

I am wondering how to test .aspx.cs and .ascx.cs code behind. Can I use unit testing and if so how? Are there alternatives that will help test the functions in the code behind files? I don't know how ...