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)

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 ...
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 ...
15
votes
6answers
787 views

From a TDD perspective, am I a bad person if I test against a live endpoint instead of a mock?

I follow TDD religiously. My projects typically have 85% or better test coverage, with meaningful test cases. I do a lot of work with HBase, and the main client interface, HTable, is a real pain ...
15
votes
8answers
893 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, ...
1
vote
1answer
80 views

TDD verifying dependency method invoked correctly

I am trying to follow TDD in my proj but I can't get my head around how to verify I am calling a dependency correctly or even if I should be trying to verify it. Here's the requirement: Write an ...
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 ...
0
votes
0answers
47 views

Adding unit tests to brownfield applications [duplicate]

I'm working for a company that has been developing a series of products for years with little to no unit testing in place. They want to move to TDD and unit test new code going forward. However, I'm ...
3
votes
5answers
203 views

Do I need a suite of unit tests for inner business-logic class? Since it's going to replicate the acceptance test suite for 90% [duplicate]

I'm new to TDD and wondering about methodolody. Given: A simple project which implements functionality of, for example, a console calculator. It has the following structure: Fairly simple ...
6
votes
3answers
399 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 ...
2
votes
3answers
494 views

Mocking static methods

Having recently returned from a Test Driven Development (TDD) course I had the following thought. While writing unit tests using Mockito we came up against of the problem of mocking static methods. ...
0
votes
1answer
125 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 ...
43
votes
14answers
4k views

Does TDD really work for complex projects?

I’m asking this question regarding problems I have experienced during TDD projects. I have noticed the following challenges when creating unit tests. Generating and maintaining mock data It’s hard ...
3
votes
4answers
212 views

Building complex algorithms with TDD

I'm trying to adopt TDD in my daily programming practice. I use it at work very effectively, but I'm having trouble with my personal projects where I'm using some complex algorithms. The particular ...
1
vote
2answers
112 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 ...
6
votes
5answers
838 views

Questions about TDD and unit testing

I am a junior software developer and I have been researching some of the practices in the industry to make myself better. I have been looking at unit testing briefly and I cannot see how the extra ...
8
votes
9answers
4k views

Is anyone doing “real” TDD with Visual-C++, and if yes, how do they do it?

Test Driven Development implies writing the test before the code and following a certain cycle: Write Test Check Test (run) Write Production Code Check Test (run) Clean up Production Code Check test ...
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. ...
1
vote
2answers
157 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 ...
4
votes
8answers
418 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 ...
69
votes
16answers
7k views

TDD negative experience [closed]

What is a negative side of your TDD experience? Do you find baby steps (the simplest fix to make test green) annoying and useless? Do you find no-value tests (when test has sense initially but in ...
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 ...
8
votes
7answers
520 views

Acceptance tests done first…how can this be accomplished?

The basic gist of most Agile methods is that a feature is not "done" until it's been developed, tested, and in many cases released. This is supposed to happen in quick turnaround chunks of time such ...
1
vote
3answers
223 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?
8
votes
5answers
522 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) ...
6
votes
2answers
489 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 ...
2
votes
2answers
248 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 ...
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 ...
20
votes
7answers
803 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 ...
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 ...
10
votes
3answers
551 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 ...
3
votes
2answers
175 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 ...
1
vote
2answers
165 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 ...
31
votes
7answers
2k 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 ...
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 ...
23
votes
5answers
18k views

What is an integration test exactly?

My friends and I have been struggling to classify exactly what is an integration test. Now, on my way home, I just realised, that every time I try to give a real world example of an integration ...
1
vote
3answers
193 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 -- ...
0
votes
1answer
142 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 ...
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) { ...
15
votes
6answers
985 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 ...
2
votes
1answer
269 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 ...
4
votes
1answer
208 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 ...
11
votes
2answers
412 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
168 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
212 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 ...
17
votes
5answers
539 views

How can I start testing in a testing anticulture?

I have a confession to make: Formalized automated testing was never a part of my programming background. I now work in a very large company with many developers (most of them web developers of one ...
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 ...
22
votes
8answers
2k views

Are “TDD Tests” different to Unit Tests? [duplicate]

I read Stephen Walther's article about Test Driven Development (TDD) and unit testing. I think it was an excellent article. The author makes a distinction between what he calls "TDD Tests" and unit ...
2
votes
1answer
585 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 ...
49
votes
16answers
3k views

Why not write all tests at once when doing TDD?

The Red - Green - Refactor cycle for TDD is well established and accepted. We write one failing unit test and make it pass as simply as possible. What are the benefits to this approach over writing ...
14
votes
4answers
2k views

Why is Conway's “Game of Life” used for code retreats?

Code Retreat is an all-day training event that focuses on the fundamentals of software development. There's a "global" code retreat day coming up, and I'm looking forward to it. That said, I've been ...