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)

6
votes
3answers
406 views

Are “Stocks” a TDD/Unit testing anti pattern?

From Martin Fowler's Mocks Aren't Stubs he states that Stubs provide canned answers to calls made during the test while Mocks objects pre-programmed with expectations which form a specification of the ...
1
vote
2answers
115 views

When changing a class/method and you already have passing unit tests, should you change then test or write a test then change?

Say I have a class with a single constructor that accepts 2 parameters and initialises itself using those parameters. I have written tests for this and they are all passing. I later realise I need to ...
4
votes
3answers
165 views

Sprint Planning Meetings - determine if a work item is “planned”?

We've been working with Scrum for a while now, generally successfully. However of late, as the pressure has started to mount up we've encountered several situations where items came through planning ...
37
votes
9answers
4k views

Do we need Logging when doing TDD?

When doing the Red, Green & Refactor cycle we should always write the minimum code to pass the test. This is the way I have been taught about TDD and the way almost all books describe the process. ...
0
votes
1answer
167 views

What kind of a test is a “consistency check”?

Some or all of the tests I write and run are checks for consistency e.g. assert that if I create a new user account, that the account that was created actually has the same name as the name that was ...
1
vote
3answers
224 views

Is it ever justifiable to write code without tests when doing TDD?

Is it ever justifiable to write production-code without also writing tests for it when doing Test Driven Development?
4
votes
8answers
437 views

How to measure that a team is doing Test Driven Development

My team is considering a department goal of doing Test Driven Development next (fiscal) year. TDD sounds good and my manager is on board. The only problem is measurement. Our company rules require ...
2
votes
2answers
254 views

On which abstraction level would you do TDD?

Problem I find myself nailing the class structure down by having too many unit tests which makes making changes hard. Example Assume we have a class A which uses classes B1 and B2. Class B1 uses ...
20
votes
7answers
820 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 ...
16
votes
8answers
1k 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, ...
10
votes
3answers
553 views

How do I stress the importance of unit tests to my manager [duplicate]

I've recently started a new job, & I've been tasked with completing a feature that another developer didn't finish before he left the company. The existing tests are out of date (i.e ...
1
vote
2answers
167 views

TDD - Making assertions about C# Expression trees

How would you unit test the PerformUpdate method in the sample below? This is a (very) simplified version of some code that performs updates against a database where the schema is dynamic and ...
3
votes
2answers
180 views

TDD workflow for (implementation specific) edge cases

When developing features with TDD, I create a test for each combination of feature and case. So, one test for creating user successfully, one for validation errors, and one for database errors. I ...
0
votes
0answers
78 views

Looking for a specific Benefits of TDD Diagram [duplicate]

I'm looking for a specific diagram I saw recently. It was a combination of three diagrams, showing A project with Test First Unit Tests having less bug fix time / system testing A project with Test ...
0
votes
1answer
143 views

In TDD, is it bad practice to pass a test with code that would pass more than one test? [duplicate]

When using TDD, is it bad practice to pass a newly written test with code that could also pass another test? For example, take the following test (in PHP) public function ...
1
vote
3answers
199 views

Debugging checklists: How much it's necessary to have? [closed]

Should making debug-checklists be an essential part of development process? How it can be integrated with unit-tests? Update Debugging checklist: Think about it as your troubleshooting checklist -- ...
33
votes
7answers
3k 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 ...
15
votes
6answers
1k views

TDD and complete test coverage where exponential test cases are needed

I am working on a list comparator to assist sorting an unordered list of search results per very specific requirements from our client. The requirements call for a ranked relevance algorithm with the ...
4
votes
1answer
233 views

Inheritance in test classes

I have an interface Serializer with methods serialize and isSerializerFor. I created a first implementation of this using TDD, and ended up with a nice clean test case fully covering a nice clean ...
1
vote
2answers
162 views

Testing Framework Selection: xUnit family theory

Background: I am familiar with xUnit family frameworks and have had experience with (shunit2, PhpUnit and simpletest). I am currently trying to find a testing framework for C++. I did a quick search ...
11
votes
2answers
414 views

Is TDD viable in collaborative open source projects

Let's say I wanted to start an open source project that I hope/expect to have many people submit patches and whatnot. Is it viable to take a strict TDD approach? Can/should I expect/trust ...
5
votes
1answer
170 views

Managing false positives in TDD or BDD

I'm relatively new to TDD and have been thinking a lot about how to manage the perpetually growing pool of tests that comes with it. One of my biggest concerns is about false positives. In my ...
2
votes
2answers
215 views

How to refactor out static members of basic classes

Currently I am working on C++ project, which can be classified as "legacy" project. A lot of poor written code was committed because of lack of experience and under the pressure of deadlines. When I ...
2
votes
1answer
625 views

How to unit test a web client?

I am having a lot of trouble understanding how to unit test my web client. I have just finished a project using TDD for the first time - this project hd no external dependencies such as API calls or ...
5
votes
3answers
4k 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) { ...
20
votes
2answers
610 views

How do I create an environment where fixing tests is seen as a priority?

I am a software engineer at a medium sized company. We have a fairly robust testing platform running on TeamCity. It does unit tests on every checkin, and a daily unit test/BVT run. The problem is ...
0
votes
1answer
182 views

Programming methodologies at stackoverflow [closed]

I am in the middle of starting up a software company where we would use ASP.NET MVC and ASP.NET WebAPI extensively at shop. We will be a group of 4 and no more than 10 will work on any particular ...
1
vote
1answer
102 views

Testing a codebase with sequential cohesion

I've this really simple program written in C with ncurses that's basically a front-end to sqlite3. I would like to implement TDD to continue the development and have found a nice C unit framework for ...
0
votes
1answer
78 views

Test Doubles : Do they go in “source packages” or “test packages”?

I've got a couple of data access objects (DefaultPersonServices.class, DefaultAddressServices.class) which is responsible for various CRUD operations in a database. A few different classes use these ...
8
votes
3answers
4k views

How can I unit test a class which requires a web service call?

I'm trying to test a class which calls some Hadoop web services. The code is pretty much of the form: method() { ...use Jersey client to create WebResource... ...make request... ...do ...
3
votes
6answers
251 views

How does TDD address interaction between objects?

TDD proponents claim that it results in better design and decoupled objects. I can understand that writing tests first enforces the use of things like dependency injection, resulting in loosely ...
19
votes
3answers
1k views

Difficulties With TDD & Refactoring (Or - Why Is This More Painful Than It Should Be?)

I wanted to teach myself to use the TDD approach and I had a project I had been wanting to work on for a while. It wasn't a large project so I thought it would be a good candidate for TDD. However, I ...
3
votes
1answer
162 views

How to deal with the notion of time in UI/Integration tests

There are some well-known techniques for dealing with the notion of time in unit tests. These allow you to write unittests that always work with a specific time so the outcome of the test is ...
16
votes
7answers
2k views

When should I write integration tests?

According to rules of TDD unit tests are written before production code, but what about Integration tests that exercises interaction between concrete (non mocks) wired objects? Should they be written ...
2
votes
1answer
158 views

Can you apply agile/TDD in all circumstances?

I'm not against agile/TDD and use it under most circumstances. However, in some circumstances I feel it doesn't work well. For example, the other day I was building a fairly complex data processing ...
4
votes
3answers
2k views

How do you unit test a User Interface? [closed]

I use JavaScript with JQuery for a Rails application. I have some dynamic behaviour in this one. As a Ruby developper, I like TDD/BDD, specialy with RSpec. For the moment, I test my JavaScript ...
48
votes
7answers
3k views

Writing Tests for Existing Code

Suppose one had a relatively large program (say 900k SLOC in C#), all commented/documented thoroughly, well organized and working well. The entire code base was written by a single senior developer ...
0
votes
1answer
480 views

Designing new application from scratch, TDD, MVC, OOD based [duplicate]

I'm about to improve my skills in all that is related to designing applications from scratch using proper OOD principles, involving MVC pattern and using TDD approach to do it. I have a project for ...
5
votes
3answers
1k views

Who should be responsible to write test cases? [duplicate]

Should tests in some project be written by the actual person that does the coding (usually senior in our team) or it can be done by junior coders with less experience?
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 ...
2
votes
4answers
652 views

How to practice ATDD if design is not yet emerged from TDD?

Despite being very stakeholders friendly, ATDD aimed to provide a "stop" line when a feature has just been done. This avoids wasting time to add non-focused (and sometimes useless) code. That's why ...
2
votes
1answer
235 views

TDD / one test representing the whole scenario ? or should I split it? [duplicate]

While practicing TDD, I came across this specification: A user should be created with its password hashed, be persisted and an activation token should be returned. Should my first unit test, (aiming ...
1
vote
1answer
863 views

Should we mock entities and value objects when doing DDD?

After reading a few articles about Newable vs Injectable objects and how these concepts relate to DDD's services, entities and value objects, I was left with some doubts about using newables in my ...
0
votes
1answer
280 views

Is it worth writing a unit test for a DTO with the most basic getter/setters? [duplicate]

The advantage is it protects your DTO against future "enhancements" ?
2
votes
1answer
272 views

How do I test this?

I've attempted test first in Ruby on Rails using Test Unit and RSpec. I'm wondering how to do test first in situations that are more closely tied to the OS/filesystem. Problem: Building a USB stick ...
9
votes
5answers
996 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 ...
5
votes
2answers
360 views

Tools that can catch “fake coverage”?

Hypothetical scenario: codebase is exercised by unit tests run by a TeamCity build-bot, that also uses the built-in dotCover tool to provide coverage metrics. The build will fail if less than X% of ...
1
vote
4answers
242 views

Writing unit test only for applications that requires them [closed]

Bit of a rant, but bear with me. People call me purist. I do not code in any way other than TDD. When I try to push TDD as a company policy, the following conversation: company owner: "we'll do TDD ...
7
votes
3answers
598 views

TDD Mock call verification - is it an anti-pattern?

I've been doing TDD for year now, I feel pretty good about it, I love my test suites and all. However I've noticed that lately I've been doing a lot of mock call verification. For example I'd have a ...
2
votes
5answers
599 views

Why is TDD not working here?

I want to write a class A that has a method calculate(<params>). That method should calculate a value using database data. So I wrote a class Test_A for unit testing (TDD). The database access ...