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)

5
votes
3answers
160 views

Should unit tests always overlap

This is a test design question. I have a class 'handler' that accepts a 'validator' that checks some business logic on what's passed to the handler. I made the unit tests for the validator and now ...
7
votes
3answers
204 views

In test-driven development, are there good reasons not to write multiple failing tests and only then to make them pass?

Uncle Bob's three rules of test-driven development state the following: You are not allowed to write any production code unless it is to make a failing unit test pass. You are not allowed to ...
0
votes
3answers
85 views

Determining the optimal amount of unit tests?

I think I may be writing -too- many unit tests. For example, say I was doing a coursework management system, and I coded a feature for submitting coursework on behalf of a student. If invalid ...
75
votes
16answers
9k 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 ...
13
votes
10answers
1k views

How to convince teammates to use TDD [closed]

I am the only person on my team that use TDD. How do I make them to use it? I am annoyed that when I pull, someone's code will break my tests and I am the one who has to fix them. Will using github, ...
0
votes
3answers
122 views

How to write testcases for a piece of logic? [closed]

I want to learn how to write testcases for a piece of logic like unit tests. Now I am not concerned about any specific framework or language, just wanted to know how can I get learn to write ...
30
votes
11answers
3k views

Writing the minimum code to pass a unit test - without cheating!

When doing TDD and writing a unit test, how does one resist the urge to "cheat" when writing the first iteration of "implementation" code that you're testing? For example: Let's I need to calculate ...
12
votes
3answers
675 views

How do I stress the importance of unit tests to my manager [duplicate]

I've recently started a new job and 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 useless)... ...
4
votes
6answers
700 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 ...
12
votes
6answers
2k 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 ...
2
votes
2answers
125 views

Are DDD aggregates a good boundary for unit testing?

An aggregate can represent a somewhat stable system boundary. Does it make sense to write input and output test aggregates to do most testing? In theory we could use an aggregate as a data driven way ...
89
votes
14answers
12k views

When is it appropriate to not unit test?

I work in a small company as a solo developer. I'm the only developer at the company in fact. I have several (relatively) large projects I've written and maintain regularly, and none of them have ...
4
votes
1answer
196 views

How to Structure Simple C++ projects for TDD

I am introducing Google Test into our development environment at work, and would like to encourage a TDD mindset, making this as accessible as possible for new developers to start using. I am looking ...
-1
votes
1answer
123 views

What is the difference between a mock and a test double? [closed]

I was reading an article here on Mocks. I would like to conclude to make my understanding more clear. Anything that can be placed in place of a real object while testing is called a Test Double. ...
3
votes
0answers
81 views

How to think about a schedule that pulls from a database as objects

I am working on a personal project using Python. I have been using version control to the best of my abilities and if you would like to check it out and run the app ...
2
votes
0answers
55 views

Should I TDD correct view returned from controller?

I have been reading the following Uncle Bob post on TDD. He explains that there are cases where TDD is not needed. Mainly in a case where your tests and code are both very specific, and your code is ...
79
votes
20answers
10k views

Why does TDD work? [closed]

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 ...
10
votes
4answers
1k views

When should I use mock objects?

I've read a lot of things about TDD but I still have doubts. For example, I have these class diagrams: It's a simple example, just to learn about TDD and mock objects. Which test should I write ...
3
votes
3answers
197 views

Unit Testing and 3rd party packages. Do I mock or not?

I'm just getting used to unit testing and on my new project I decided to adopt a TDD approach. My code below is to test the UserServices class which is responsible for creating a user, deleting a ...
0
votes
2answers
191 views

Should a Junior programmer add TDD tests to mvc project

I'm a junior programmer near to my 6 month probation, following my initial career changing 3 month assignment in which I added TDD tests and wondering whether I should add tests to my current work. ...
-2
votes
3answers
166 views

What is the most elemental workflow for TDD?

Gradle is such an interesting build tool that it prompted me to look at Spock and JUnit -- which I've never done before. What is the basic workflow with TDD? My approach has been to do frequent ...
4
votes
2answers
97 views

How do you evaluate automated testing for a particular product/project?

Automated testing is pretty hyped-up in recent years, with particular emphasis on TDD at the "unit" level. The touted advantages include things like: Stabilizing existing code: breaking changes are ...
13
votes
8answers
5k views

How do I do TDD on embedded devices?

I'm not new to programming and I've even worked with some low level C and ASM on AVR, but I really can't get my head around a larger-scale embedded C project. Being degenerated by the Ruby's ...
3
votes
2answers
203 views

Differences between Given When Then (GWT) and Arrange Act Assert (AAA)?

In TDD there is Arrange Act Assert (AAA) syntax: [Test] public void Test_ReturnItemForRefund_ReturnsStockOfBlackSweatersAsTwo_WhenOneInStockAndOneIsReturned() { //Arrange ShopStock shopStock ...
0
votes
3answers
122 views

At what point in a projects life-cycle do you begin writing tests? [duplicate]

I'm not in the field, so I don't have any professional experience from projects following the TDD design. I am trying to adopt this pattern, but I'm confused as to when I start actually writing the ...
14
votes
4answers
1k 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
1answer
65 views

TDD with a half baked Java EE application

I am a second year Computer Science student currently on a placement and I am currently developing a Java EE application that collects meta data from several sources and then visualises the data. This ...
4
votes
2answers
1k views

How do you unit test \ use TDD methods for ETL's and reporting projects?

ETL projects are projects created using an ETL (Extract - Transform - Load) tool such as SSIS, PowerCenter,etc These typically involve reading data from an external source, loading it to a staging ...
6
votes
2answers
291 views

How does breaking up a big method into smaller methods improve unit testability when the methods are all private?

I'm presently reading Building Maintainable Software by Joost Visser and some of the maintenance guidelines they recommend include: A) each unit/method should be short (less than 15 lines per method) ...
9
votes
5answers
918 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. ...
15
votes
2answers
848 views

Software Testing Techniques or Categories [closed]

What kinds of software testing do you know? I've heard about Test-Driven Development, Unit tests etc, but can't understand their importance and difference. For example, why are we using regression ...
5
votes
5answers
400 views

TDD: Write a separate test for object initialization or relying on other tests exercising it

This seems to be the common pattern that's emerging in some of the tests I've worked on lately. We have a class, and quite often this is legacy code whose design can't be easily altered, which has a ...
3
votes
1answer
103 views

How to move Python doctest examples into another unit test framework?

Years ago AFAIK the mathematitician and software developer Tim Peters discovered that very often the documentation of APIs tends to get out of date over time during the software live cycle, because ...
9
votes
2answers
466 views

Why is it inappropriate to use UML diagrams to plan how your code will be organized?

So, yes, diagrams can be inappropriate at times. When are they inappropriate? When you create them without code to validate them, and then intend to follow them. There is nothing wrong with ...
5
votes
5answers
360 views

Can we add methods which is easier for assertion in test and which is only used in tests when TDD?

Here let me take a simple parking boy example. A parking boy can manage several parking lots, and when a car comes, he will park the car into some parking lot and can also help to un-park the car. ...
0
votes
1answer
62 views

Reusing array with static test data across test classes

I have a Map which takes in an a String key, and an array of custom objects as the value. the map usually contains two entries, and the arrays for both entries never change in terms of data; once they ...
40
votes
7answers
20k views

Difference Between Unit Testing and Test Driven Development

From reading the descriptions, I understand that in TDD tests are done prior to writing the function and in Unit Testing, its done afterwards. Is this the main difference, or the two terms can't even ...
0
votes
4answers
625 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 ...
14
votes
3answers
3k views

Relation between BDD and TDD

What is the relation of BDD and TDD? From what I understood BDD adds two main things over TDD: tests naming (ensure/should) and acceptance tests. Should I follow TDD during development by BDD? If ...
0
votes
1answer
157 views

Testing a function that only calls one or two other functions [duplicate]

The short version The code As part of TDD, we often end up with functions that follow this pattern: function onSendRequestForSelected() { this.deselectStepsWithRequest(); ...
23
votes
11answers
2k views

Automated Testing: Explaining its Business Value

To start I don't think this is a repeat of other questions on unit testing. What I'm looking for help with is articulating its value to a team of programmers, analysts, managers and testers. By ...
32
votes
10answers
5k views

Should we test all our methods?

So today I had a talk with my teammate about unit testing. The whole thing started when he asked me "hey, where are the tests for that class, I see only one?". The whole class was a manager (or a ...
6
votes
2answers
297 views

Going TDD in the middle of the project

They want us to develop new features of a product with TDD. I know that they don't usually write tests for legacy code of already developed modules. But yet, what if new features have to be added to ...
2
votes
1answer
163 views

TDD: How to test domain model

When practicing TDD, how do you test a domain model? If you don't test, how do you account for code coverage? We want to have 100% coverage (or as much as possible), but despite hours of training ...
1
vote
1answer
52 views

What is the preferred way of preparing data in automatic testing

Lets say I want to test a method of a class representing a user account. I have a fixture which contains several user records from which I want to choose one. What is the preferred method here? Pick ...
0
votes
1answer
126 views

TDD - Outside In developemnt

I'm pretty comfortable with the core concepts of Outside In (especially from this question). However one thing eludes me concerning the mocks you created at each level which then lead to creating the ...
1
vote
2answers
165 views

Ways of creating expected object for assert

Recently, I started to use TDD. It's really cool and fun but creating expected object for assertEquals is very boring and tedious. At the moment I see only two way for that: Straightforward Creating ...
7
votes
3answers
5k views

Who should be responsible to write test cases? [duplicate]

Should tests in some project be written by the actual person that does the coding (usually senior in our team) or it can be done by junior coders with less experience?
0
votes
1answer
216 views

How to test an algorithm with multiple inputs?

I want to check group of algorithms which has up to 8 input options. The native idea would be to check all possibilities via brute force. How can I reduce it without leaving out required combinations? ...
-2
votes
3answers
154 views

TDD/BDD: Mocks with expectations: bad? [closed]

Is using mocks in the following way a bad idea: writing tests where mocks expect certain calls from the subject under test Or even just writing mocks that return values to the subject under test ...