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)

2
votes
5answers
470 views

DRY code, DRY tests?

At some point I had to create some class "Class1" and that class needs a method "method". So I have the following: Class1MethodTest: A total of N tests that check the behavior of Class1.method Class1 ...
12
votes
5answers
850 views

Types of unit tests based on usefulness

From value point of view I see two groups of unit tests in my practice: Tests that test some non-trivial logic. Writing them (either before implementation or after) reveals some problems/potential ...
1
vote
2answers
1k views

Testing ASP.NET .aspx and .ascx code behind files

I am wondering how to test .aspx.cs and .ascx.cs code behind. Can I use unit testing and if so how? Are there alternatives that will help test the functions in the code behind files? I don't know how ...
4
votes
1answer
271 views

If TDD is design, how do you know your TDD is well designed? [duplicate]

Given a large group (50+) of programmers: All given the same problem, All using Test-Driven Development (TDD), All pair programming, All doing group-based code review, I have personally seen the ...
4
votes
5answers
341 views

Are there any cases when one should not use Test Driven Development? [duplicate]

Is it recommended that TDD be always practiced in a project, or are there cases when it should be avoided? Should we all adopt TDD? Is it standard practice in major software companies?
3
votes
2answers
341 views

Unit testing behaviours without coupling to implementation details

In his talk TDD, where did it all go wrong, Ian Cooper pushes Kent Beck's original intention behind unit testing in TDD (to test behaviours, not methods of classes specifically) and argues for ...
0
votes
2answers
136 views

Characterization in Testing: Unit test or Functional test [duplicate]

So I'm trying to push for more automated testing in my company, which focus a lot on prototype and proof of concept systems. We currently use Google Test for unit testing. This tests specific test ...
8
votes
5answers
832 views

Why write tests for code that I will refactor?

I am refactoring a huge legacy code class. Refactoring (I presume) advocates this: write tests for the legacy class refactor the heck out of the class Problem: once I refactor the class, my ...
1
vote
1answer
87 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 ...
16
votes
6answers
860 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 ...
0
votes
0answers
48 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
230 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 ...
2
votes
3answers
1k 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. ...
4
votes
4answers
266 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 ...
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
3answers
438 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
123 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
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 ...
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
171 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
230 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
508 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
260 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 ...
21
votes
7answers
847 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
563 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
190 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
202 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
146 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 ...
2
votes
3answers
230 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 -- ...
36
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
307 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
176 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
441 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
175 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
234 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
918 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 ...
6
votes
3answers
6k 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
617 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
214 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
107 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
79 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
6k 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
299 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
2k 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
168 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
163 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 ...