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)

3
votes
1answer
412 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
398 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
456 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 ...
4
votes
3answers
1k views

TDD in JavaScript [closed]

I'm about to participate in a Coding Kata and I would like to do it in JavaScript. What tools and libraries do I need for TDD in JavaScript?
5
votes
5answers
452 views

Test driven vs Business requirements constant changing

One of the new requirement of our dev team set by the CTO/CIO is to become test driven development, however I don't think the rest of the business is going to help because they have no sense of ...
6
votes
3answers
2k views

How do you handle increasingly long compile times when working with templates?

I use Visual Studio 2012 and he have cases where we added templates parameters to a class "just" in order to introduce a "seam point" so that in unit-test we can replace those parts with mock objects. ...
2
votes
2answers
236 views

Unit test and Code Coverage of Ant build scripts

In our development environment We have more and more build scripts for ant to perform the build tasks for several different build jobs. These build scripts sometimes become large and do a lot of ...
8
votes
5answers
533 views

How to TDD test that objects are being added to a collection if the collection is private?

Assume that I planned to write a class that worked something like this: public class GameCharacter { private Collection<CharacterEffect> _collection; public void Add(CharacterEffect e) ...
-2
votes
2answers
492 views

How can I test database access methods in Java? [closed]

I want to write a test for a method that accesses a database such as following. public class MyClass{ public String getAddress(Int id){ String query = "Select * from Address where ...
4
votes
3answers
521 views

What if I can't make my unit test fail in “Red, Green, Refactor” of TDD?

So let's say that I have a test: @Test public void MoveY_MoveZero_DoesNotMove() { Point p = new Point(50.0, 50.0); p.MoveY(0.0); Assert.assertAreEqual(50.0, p.Y); } This test then ...
8
votes
3answers
342 views

What to do when TDD tests reveal new functionality that is needed that also needs tests?

What do you do when you are writing a test and you get to the point where you need to make the test pass and you realize that you need an additional piece of functionality that should be separated ...
6
votes
1answer
703 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 ...
4
votes
4answers
342 views

Are injectable classes allowed to have constructor parameters in DI?

Given the following code: class ClientClass{ public function print(){ //some code to calculate $inputString $parser= new Parser($inputString); $result= ...
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 ...
2
votes
2answers
226 views

Returning a mock object from a mock object

I'm trying to return an object when mocking a parser class. This is the test code using PHPUnit 3.7 //set up the result object that I want to be returned from the call to parse method ...
4
votes
4answers
178 views

How to implement isValid correctly?

I'm trying to provide a mechanism for validating my object like this: class SomeObject { private $_inputString; private $_errors=array(); public function __construct($inputString) { ...
3
votes
5answers
727 views

“TDD is about design, not verification”; concretely, what does that mean?

I've been wondering about this. What do we exactly mean by design and verification. Should I just apply TDD to make sure my code is SOLID and not check if it's external behaviour is correct? Should ...
0
votes
3answers
423 views

Introduce unit testing when codebase is already available [duplicate]

Possible Duplicate: Best practices for retrofitting legacy code with automated tests I've been working on a project in Flex for three years now without unit testing. The simple reason for ...
3
votes
1answer
1k views

How to unit test image processing code?

I'm working in image processing (mainly OCR) and I wonder how I should integrate unit tests in my development. I'm already using unit tests for more "common" type of code but when dealing with image ...
23
votes
4answers
3k views

TDD - Outside In vs Inside Out

What is the difference between building an application Outside In vs building it Inside Out using TDD? These are the books I read about TDD and unit testing: Test Driven Development: By Example ...
7
votes
4answers
735 views

Unit testing and Test Driven Development questions

I'm working on an ASP.NET MVC website which performs relatively complex calculations as one of its functions. This functionality was developed some time ago (before I started working on the ...
3
votes
2answers
856 views

How to organize unit/integration test in BDD

So finally after reading a lot, I have understood that the difference between BDD and TDD is between T & B. But coming from basic TDD background, what I used to was, first write unittest for ...
7
votes
1answer
361 views

Test Driven Development Code Order

I am developing my first project using test driven development. I am using Zend Framework and PHPUnit. Currently my project is at 100% code coverage but I am not sure I understand in what order I am ...
0
votes
3answers
364 views

What's wrong performing unit test against concrete implementation if your frameworks are not going to change?

First a bit of background: We are re-architecting our product suite that was written 10 years ago and served its purpose. One thing that we cannot change is the database schema as we have 500+ client ...
2
votes
3answers
583 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 ...
4
votes
1answer
502 views

Test-Driven Development with plain C: manage multiple modules

I am new to test-driven development, but I'm loving it. There is, however, a main problem that prevents me from using it effectively. I work for embedded medical applications, plain C, with safety ...
3
votes
3answers
878 views

How do I make code bound to an ORM testable?

In Test Driven Development, how do I make code bound to an ORM testable? I am using a Micro-ORM (PetaPoco) and I have several methods that interact with the database like: AddCustomer UpdateRecord ...
9
votes
4answers
816 views

How to unit test a function that is refactored to strategy pattern?

If I have a function in my code that goes like: class Employee{ public string calculateTax(string name, int salary) { switch (name) { case "Chris": ...
7
votes
1answer
289 views

Who should initialize dependencies in a TDD application?

I'm trying to learn implementing TDD with mocking/fake objects. One of the questions I have is how to initialize a dependency in an application which implements TDD? An example from this article ...
7
votes
4answers
373 views

How would a new language look if it was designed from scratch to be easy to TDD?

With the some most common languages (Java, C#, Java, etc) it sometimes seems that you are working at odds with the language when you want to fully TDD your code. For example, in Java and C# you will ...
11
votes
4answers
956 views

TDD with SQL and data manipulation functions

While I'm a professional programmer, I've never been formally trained in software engineering. As I'm frequently visiting here and SO, I've noticed a trend for writing unit tests whenever possible ...
4
votes
1answer
187 views

What is a “behavior rich object” and why would it be advantageous?

I am referring to the article Mocks aren't Stubs by Martin Fowler. When naming cases when he think "mockist" TDD will be advantageous, he said It's particularly worth trying if you are having ...
7
votes
5answers
584 views

Is it typical for a unit test suite to be larger than the code it tests? [duplicate]

Possible Duplicate: What is a normal “functional lines of code” to “test lines of code” ratio? I've found that more often than not, when you write lots of unit ...
13
votes
5answers
1k views

Does following TDD inevitably lead to DI?

I learned to do Test Driven Development (TDD), Dependency Injection (DI) and Inversion of Control (IoC) all at the same time. When I write code using TDD I always end up using DI in my class's ...
7
votes
5answers
666 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 ...
10
votes
5answers
491 views

Methods for testing a very large application

I have a PHP app which is very large. There are usually 2-3 developers working on it full time and we are getting to the point where we are making changes and creating bugs (cough features!). The ...
5
votes
6answers
421 views

Sporadic unittests or TDD?

I've read some basics about unit tests and TDD, but I find it hard to convince myself why TDD can have an advantage over only selected unittests. I've read common arguments for TDD, but don't see the ...
12
votes
3answers
4k views

Unit testing C++: What to test?

TL;DR Writing good, useful tests is hard, and has a high cost in C++. Can you experienced developers share your rationale on what and when to test? Long story I used to do test-driven development, ...
2
votes
3answers
120 views

Post-hoc testing in TDD recommended?

I have a personal project that doesn't have robust testing. I had a bit of TDD going on at the beginning, but it quickly became counterproductive as the project details changed dramatically over time. ...
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 ...
17
votes
4answers
1k views

Implementing unit testing at a company that doesn't do it

My company's head of software development just "resigned" (i.e. fired) and we are now looking into improving the development practices at our company. We want to implement unit testing in all ...
1
vote
3answers
536 views

test coverage reality

I am NOT doing test driven development and I write my test classes after the actual code is written. In my current project I have a test coverage (Line coverage) of 70% for 3000 lines of Java code. I ...
1
vote
4answers
1k views

Moving from mock to real objects?

I'm like doing TDD so I started everything mocking objects, creating interface, stubbing, great. The design seems to work, now I'll implement the stuff, a lot of the code used in the stubs are going ...
5
votes
4answers
302 views

Testing To Prevent Cascading Bugs

Yesterday, Twitter was hit with a "Cascading Bug" as described in this blog post: A “cascading bug” is a bug with an effect that isn’t confined to a particular software element, but rather its ...
17
votes
5answers
6k views

What are the design principles that promote testable code? (designing testable code vs driving design through tests)

Most of the projects that I work on consider development and unit testing in isolation which makes writing unit tests at a later instance a nightmare. My objective is to keep testing in mind during ...
16
votes
9answers
1k views

Are too many assertions code smell?

I've really fallen in love with unit testing and TDD - I am test infected. However, unit testing is normally used for public methods. Sometimes though I do have to test some assumptions-assertions ...
17
votes
10answers
2k views

Is 100% code coverage a pipe dream?

Is it feasible to expect 100% code coverage in heavy jquery/backbonejs web applications? Is it reasonable to fail a sprint due to 100% coverage not being met when actual code coverage hovers around ...