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)

4
votes
3answers
113 views

Test Driven Development when the specifications change

These days, it's fairly common for me to be tasked to make a change that actually breaks the prior spec. I know that one of the major ideas behind TDD is to have a suite that verifies all your changes ...
10
votes
6answers
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 ...
1
vote
1answer
75 views

Unit test approaches other than test-first and test-last? And what about variants of them? [closed]

I'm wondering if there are other approaches, old or new, to writing unit tests, and how viable they are, other than the traditional and tdd unit testing approaches. I know there is behavior-driven ...
1
vote
3answers
68 views

Generating test data for a search application

I have a general question about testing search applications, and what I'm looking for is pointers to resources on the topic that I can go and research on my own. I've tried semi-informed, ...
9
votes
5answers
958 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": ...
1
vote
2answers
72 views

Should you mock key-value stores/aggregators

I've always been taught that your tests should run in isolation, and other than a db for ActiveRecord etc., your tests should not rely on any external software/services. e.g. I always mock my other ...
0
votes
2answers
53 views

Unit testing the variables passed to the view from the controller

Let's say I want to test a controller that gets some value from a service and then pass some of all of those values to the view. Do you test that the view gets the result that the controller took ...
11
votes
4answers
730 views

Is it OK to introduce methods that are used only during unit tests?

Recently I was TDDing a factory method. The method was to create either a plain object, or an object wrapped in a decorator. The decorated object could be of one of several types all extending ...
0
votes
2answers
212 views

Should a class validate argument using external method/service with unit testing?

I have a class that runs as a service and returns html code of a website when supplied with a URL. The code: public interface IHtmlDownloader { IWebProxy Proxy { get; set; } string UserAgent ...
6
votes
6answers
468 views

I'm confused about which is the correct way to work with TDD

I'm trying to grasp what's the idea behind TDD and how a team is supposed to work with it. I have the following test case with NUnit + Moq (just writing by memory, it is not assured the example ...
8
votes
5answers
584 views

How to do Test Driven Development

I have just 2+ years of experience in application development. In those two years my approach towards development was as following Analyze requirements Identity Core component/Objects, Required ...
0
votes
3answers
125 views

What's the idea behind mocking data access in unit tests [duplicate]

I understand that you're not actually supposed to hit the database or disk when doing unit tests... Why is that? Also, taking something like Moq, what is it actually supposed to mock and where? For ...
2
votes
1answer
278 views

2 questions about TDD

I'm just starting to get to grips with TDD, and I have 2 quick questions; I'm assuming that if I were writing software for a software company, that TDD would work alongside the software design? i.e ...
70
votes
20answers
8k 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 ...
0
votes
1answer
84 views

More appropriate to validate a dependency filter parameter by mock+stub or by expression compile?

My lead is enforcing TDD on our project. He says he's following Uncle Bob (Robert Martin) and SOLID principles. One of the rules he's reinforcing is what I call "the single cog rule"--there should be ...
4
votes
2answers
254 views

Whose responsibility is it to create the interface and/or acceptance testing? Developer or QA?

I am a backend developer and always create tests for my applications. Recently I study and apply the interface tests (using selenium), but I doubted whether I who should create these tests, developer ...
9
votes
3answers
722 views

In TDD should I have to write Test first or Interface first?

I am learning TDD using c#, as far as I know test should drive the development, that is first write a failing test after write the bare minimum code to pass the test then do refactoring. But it is ...
0
votes
2answers
75 views

Should I put the name of the method I'm testing in the Unit Test method's name/assert message?

Given that a method's name might change in time, is it a good idea to specify the name of the method whose return value I am asserting as a part of the Unit Test method's name? What about the message ...
-1
votes
1answer
91 views

Do you spend your effort to reuse obsolete unit tests or rewrite them entirely? [closed]

I have this javascript project which has a unit test suite(about 200unit tests) that covers about 11.31% of the code that it was testing. The project has evolved greatly but the unit tests where never ...
8
votes
6answers
1k views

Do you really have to do BDD/TDD in a test first manner?

Even though I haven't been in a TDD or BDD project, or I have been in some that say they are doing TDD but are pretty far from it, these are things that I think about and really try to read as much as ...
13
votes
3answers
389 views

Orthogonality of unit tests vs. concision of unit tests

I'm writing unit tests for a steering system for a video game. The system has several behaviours (avoid this area because of reason A, avoid this area because of reason B, each adding a bit of context ...
4
votes
5answers
235 views

If we have TDD and BDD why do we need QA for? [duplicate]

If we have TDD and BDD why do we need QA for? Isn't the job of the developer to write bugs or failing tests? If this is true how a QA fit in? Thanks.
2
votes
5answers
179 views

TDD: how to test file outputs?

I'm really new to TDD, so I guess this question is pretty basic. We're building a website, and part of the functionality is generating some files (binary files: Excel, PDF, whatever). How should I ...
42
votes
9answers
6k 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 ...
67
votes
16answers
10k 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 ...
1
vote
2answers
106 views

In the BDD paradigm why should the “ubiquitous language” be merely semi-formal and not completely formal?

Here's the relevant quote: A common risk with software development includes communication breakdowns between Developers and Business Stakeholders. BDD uses the specification of desired behavior as ...
8
votes
2answers
218 views

Test Driven Development for Complex Games

I'm coding a game in my spare time, but I am mostly still a beginner when it comes to programming. I'm sorry if this question is off topic or if it ends up not being helpful to anyone else, but ...
1
vote
2answers
145 views

BDD/TDD - exhaustively testing details which are low-level, but still behaviour

We're looking to concentrate more on testing behaviour (as opposed to every class/method individually) in all our automated tests, as espoused by various high-profile online discussions recently. I ...
0
votes
0answers
48 views

Mixing newable and injectable in a Callable

I recently read http://misko.hevery.com/2008/09/30/to-new-or-not-to-new/ which discussed newable vs injectable objects. What would you do if you needed to make a Callable that talks to some service ...
4
votes
4answers
319 views

Test-Driven Design is not Unit Testing [closed]

Ran across this statement by Martin Fowler circa 2002: Unit testing in XP is often unlike classical unit testing, because in XP you're usually not testing each unit in isolation. You're testing ...
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
1answer
380 views

Testing strategy for games

I've inherited a web-based educational game. Over the past year I've worked towards stabilizing the code and adding new features. Most of the logic is in the front-end, so back-end unit tests, while ...
147
votes
16answers
12k 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. ...
0
votes
3answers
93 views

Is it anti-pattern to mix unit test and web test? [duplicate]

It is a language agnostic question, e.g. I have a unit test like # Unit test User user = User.create('john'); assertEquals("User name is john", "john", user.getName()); # Web test start from here ...
2
votes
2answers
44 views

Isolated Unit Tests and Fine Grained Failures

One of the reasons often given to write unit tests which mock out all dependencies and are thus completely isolated is to ensure that when a bug exists, only the unit tests for that bug will fail. ...
1
vote
2answers
484 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 ...
2
votes
1answer
119 views

How is the correct way of writing TDD for a void API?

Ok so my scenario is this: I have a third party component that offers an API for communicating with an external system. The method calls for commanding the external system to do stuff, all return ...
4
votes
2answers
133 views

Is it ok to write “extra” unit tests?

My understanding of how TDD should work is that you write a failing test for the next bit of functionality you want to add to a function or object, code until the test passes and then write the next ...
0
votes
3answers
187 views

Drawback of using static method [duplicate]

For methods that never access instance variable or static variable and they act just like a function (name-spaced) and they are deterministic base on only the input arguments , I want to ask, are ...
5
votes
1answer
154 views

Testing that an attribute does not exist cannot fail when writing tests before code

I have been taught to follow the Red->Greeen->Refactor pattern when doing TDD. There have been situations where this pattern have not been applicable though. For instance, a test to make sure that a ...
49
votes
7answers
4k 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 ...
1
vote
1answer
70 views

Question about mocking externals [duplicate]

at company we're developing quite a big project and we're arguing at the testing strategy. The question is: should all of the tests be executed in isolation of external services like database or APIs ...
1
vote
3answers
174 views

Protected variable & protected method in the era of TDD [closed]

I understand protected method is good for unit testing since you can easily mock by the class by overriding the protected method for the sake of testing. However, protected variable is just a global ...
24
votes
6answers
2k views

Sense of unit tests without TDD

We have new (quite big) project starting, that we planned to develop using TDD. The idea of TDD failed (many business and non-business reasons), but right now we have a conversation - should we write ...
0
votes
2answers
71 views

how to write unit test for AND logic gate

I'm learning about unit tests, and have a doubt for a test i want to do, to implement an "AND" logic gate A B A^B 0 0 0 0 1 0 1 0 0 1 1 1 how can i test for a method that works ...
2
votes
1answer
80 views

Wrapping function in closures to make testable functions

In my nodejs project, I have functions like this for socketio. socket.on('draw', function (data) { socket.broadcast.to(socket.room).emit('draw', data); addEvent(socket, ["draw", data]); }); ...
3
votes
4answers
197 views

How to identify and run the most relevant automated tests?

Suppose you have a reasonably large codebase (0.5 - 1 msloc) with a large test-suite (6-7hr single-threaded runtime; with a mix of unit-tests and integration-tests built with different tools). You ...
4
votes
1answer
77 views

Keep or discard tests that use methods now private [duplicate]

When writing object-oriented code from scratch, I try to follow these steps: Write a test that fails. Write a function that makes the test pass. When enough tests and functions are complete, ...
17
votes
4answers
933 views

How can I use unit tests and TDD to test an app that relies mostly on database CRUD operations?

At work, one of my projects is mostly about taking data passed in from an external client and persisting it in a database. It's a Java enterprise app using JPA and most of our logic revolves around ...
4
votes
3answers
177 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 ...