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)

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 ...
6
votes
2answers
503 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 ...
3
votes
3answers
172 views

When to write tests for a new class using BDD?

I've been practicing behaviour driven development (BDD). I understand that you have to write tests that test the behaviour of the code, and this will allow the design of your code to evolve and take ...
14
votes
6answers
936 views

TDD and Version Control

I am currently learning about TDD and trying to put it into practice in my personal projects. I have also used version control extensively on many of these projects. I am interested in the interplay ...
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, ...
6
votes
4answers
2k 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 ...
1
vote
1answer
94 views

Production or Custom Test Data for Unit Testing?

I've recently had a little disagreement with fellow developers. We're transforming various ontologies from the original source format (Pica+, RDF, etc) into our data format and have several converters ...
1
vote
2answers
371 views

Fundamental TDD: stuck with writing a test so I can write code that I want

I have a Season class. This Season has a few properties: among them, a list of Games. This should be populated from the same source that populated the rest of the Season properties. I have a test ...
3
votes
1answer
173 views

Shared context: good or bad?

RSpec allows users to share context across tests / examples, which would reduce the number of code lines in my app by a significant amount. On the other hand, somehow related to the question of ...
5
votes
2answers
1k views

A weakness of the TDD method?

This is in summary the TDD method: Write a test check if thes test fails write production code run test I think that TDD as presented works only in ideal circumstances. I'll take a simple ...
-2
votes
1answer
171 views

Do you unit-test your PODs? [closed]

do you create unit-tests for PODs (Plain Old Data Structure)? And why? I'm interested in your opinions. Regards Tobias
1
vote
2answers
259 views

How do you test database abstraction in PHP?

I apologise in advance if this question is too subjective but I'm struggling to find a good answer, probably as there is not really a correct answer to give. I'm currently writing a database ...
2
votes
1answer
258 views

Why do we write our specs in different files from our source?

The D Programming Language supports writing unit tests inline with source. There's a Ruby gem called test_inline that lets you write specs in the same file as your code. Why is it generally ...
3
votes
1answer
119 views

Stubbing and mocking boundaries

Suppose I'm building a JSON API and would like to include an endpoint that returns a list of recently created posts. Somewhere in my system is an existing Post model with the following test: create ...
11
votes
3answers
584 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 ...
2
votes
5answers
471 views

How to time the sprints in Scrum to allocate time for TDD?

We have sprints of 4 weeks duration. What I have been doing is 3 weeks dev time and 1 week of pure manual/automated testing, stabilization and shipment assurance testing. How to manage TDD within ...
3
votes
5answers
3k views

Understanding unit tests/TDD for ASP.NET webforms [closed]

I'm the lead programmer at a small software firm (currently 4 developers including myself), we develop bespoke ASP.NET WebForms applications for businesses. I joined there in 2010 just after ...
6
votes
3answers
726 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 ...
1
vote
1answer
411 views

What's the next logical TDD move in this learning example?

I'm inching my way up the TDD ladder and I've got to a point where I'd like to get advice on the "next move". I realize there might not be a single answer here, so any logical suggestion would be ...
0
votes
2answers
429 views

Should I use TDD and BDD if my project is changing fast?

I have my own little project I am creating using RoR, I plan it to have small-medium load. With no doubt I started with BDD and TDD (Cucumber and RSpec to be exact, but I am also experienced with ...
11
votes
1answer
684 views

Is there a modern replacement for a mutation testing tool like Jester for Java?

“Why just think your tests are good when you can know for sure? Sometimes Jester tells me my tests are airtight, but sometimes the changes it finds come as a bolt out of the blue. Highly ...
3
votes
2answers
223 views

Do I need to learn python first to understand the part 2 of the book Test Driven development?

It seems like Python is used as a coding language for part 2 of Kent Beck's book Test Driven Development. I have read the first part of that book and started appreciating the value of TDD . First part ...
4
votes
2answers
310 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 ...
17
votes
4answers
2k views

Why is test driven development missing from Joel's Test?

I was reading this blog by Joel Spolsky about 12 steps to better code. The absence of Test Driven Development really surprised me. So I want to throw the question to the Gurus. Is TDD not really worth ...
8
votes
1answer
772 views

Unit testing on visualization (3D graphics) frameworks

This is a follow up to this question. There I was asking how to do unit testing when you have a library of scientific algorithms. I have a similar problem now but with a different project. I'm ...
11
votes
1answer
826 views

Should I write a test to prove that deleting code fixes a bug?

Occasionally I'll run into the situation where fixing a bug requires that I delete a section of code. The TDD purist would (I assume) advocate writing a failing test, deleting the code, then watching ...
2
votes
2answers
597 views

Functional testing and Acceptance testing leading to redundant code

What I know is: A Functional test aims to test a single component (like a WebApp's Controller) from the point of view of the developer. => Did I achieve all the requirements to make it work well? ...
2
votes
2answers
293 views

organising classes / folder structure for TDD-based development

Due to test-driven development, one ends up with many classes doing just one thing. It is quite a headache just to see where such classes would be placed inside the folder structure. First of all, ...
9
votes
2answers
269 views

Should I refactor my unit tests when I extract a class out of the System Under Test?

I wrote this class that does a few things (perhaps this is a violation of the Single Responsibility Principle). I realize now that some other part of the project needs a piece of that logic and the ...
12
votes
8answers
394 views

Alternative to “Passing/Broken build” indicator?

When having a continuous integration executing the tests at each commit, a common best practice is to have all the tests passing at all times (aka "do not break the build"). I find some problems with ...
6
votes
2answers
1k views

Helper static methods in TDD

I am creating an application which will be testable(unit + integration). In this application I have a FileHelper static class, public static class FileHelper { public static void ...
5
votes
2answers
385 views

Write tests for unit tests in TDD?

In an answer to another question, I suggested creating a randomized value for input to a specific method. In my experience this has been useful for making tests more readable and it lets you skip the ...
5
votes
2answers
242 views

How to setup TDD environment

In TDD, is it good practice to keep the tests in the same directory as the code its testing or is it better separate the tests in either a different directory or a separate project. Would it be 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. ...
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 ...
5
votes
7answers
349 views

Test driven development when implementing a flexible length list

According to the commonly used TDD strategy, to implement something, you write a test that fail the code first, write the simplest code, refactor, and then repeat. I am trying to imagine this scenario ...
6
votes
2answers
682 views

Unit Test Friendly Domain Driven Design

Many of the readings I've done on DDD, both in books and online, seem to represent code that, often times, is difficult or impossible to unit test. For example, there are numerous samples with static ...
25
votes
11answers
4k views

How do we make unit tests run fast?

We have reached the point in our project where we have almost a thousand tests and people have stopped bothering with running them before doing a check in because it takes so long. At best they run ...
5
votes
3answers
474 views

How much to test in TDD?

I am newbie to TDD (writing first project following TDD practices). I have fairly basic interface IProfiler and an implementation Profiler. interface IProfiler { bool IsBusy {get;} long Elapsed ...
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 ...
3
votes
2answers
177 views

Is it okay to mock multiple objects in one class?

For developers with extensive experience using mocks, is it okay to mock multiple objects in one class (ie satisfy multiple interfaces) or is this not recommended? I am wondering because mocks are ...
10
votes
2answers
245 views

How would type errors be detected while creating mocks in a dynamic language?

The problem occurs while doing TDD. After a couple of test pass, the return types of some class/module change. In a statically typed programming language, if a previous mocked object was used in the ...
8
votes
5answers
484 views

How to understand and debug legacy software? [duplicate]

Possible Duplicate: I’ve inherited 200K lines of spaghetti code — what now? Not long ago my company placed me in a team that deals with some of the most complex bugs that are in production. ...
3
votes
1answer
403 views

TDD and test automation in applications heavily dependent on databases and user input [closed]

Recently I have been reading online about eXtreme programming and agile practices. I wish to adapt them. However most of my code is all in PHP which is the normal CRUD type web applications. Moreover ...
3
votes
2answers
142 views

Requesting quality analysis test cases up front of implementation/change

Recently I have been assigned to work on a major requirement that falls between a change request and an improvement. The previous implementation was done (badly) by a senior developer that left the ...
4
votes
5answers
222 views

Review tests first

I am going to adopt TDD in our team and one of the ideas I have is to review tests first. So one would write interfaces, mocks, and tests first, submit them for a code review and once interfaces and ...
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 ...
8
votes
4answers
394 views

How to get initial API right using TDD?

This might be a rather silly question as I am at my first attempts at TDD. I loved the sense of confidence it brings and generally better structure of my code but when I started to apply it on ...
1
vote
2answers
444 views

In which cases Robolectric is a relevant solution? [closed]

As you may now, Robolectric is a framework that provides stubs for Android objects, in order to make tests runnable outside the Dalvik environment. My concern is that, by doing this, one can fake a ...