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)

0
votes
0answers
15 views

AutoFixture Problems with simple Types

I am trying to do TDD (I am a beginner in TDD) in my current project (WPF application, MVVM, C#) and use following frameworks for my tests: NUnit AutoFixture I have a ViewModel-class that I want ...
4
votes
2answers
93 views

How would one test a function with a large number of scenarios?

I've heard that it's ideal to have one assert (or expect or should, etc) per aspect of a component's behavior you're trying to test. Is this how it works? An addOne function would be tested like this, ...
64
votes
10answers
6k views

Where is the line between unit testing application logic and distrusting language constructs?

Consider a function like this: function savePeople(dataStore, people) { people.forEach(person => dataStore.savePerson(person)); } It might be used like this: myDataStore = new Store('some ...
2
votes
2answers
1k views

C++ TDD open source projects [closed]

Are there any open source projects out there that are written in C++ in an agile way (TDD maybe)? I am trying to contribute to a C++ open source project in order to catch up with the language and I am ...
19
votes
6answers
3k 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 ...
4
votes
3answers
167 views

Role and importance of static method in OOP

Background Thinking about OOP I feel that it binds data and behavior together, taking the real world example we already have array data type which is a collection of homogeneous type but in Java we ...
4
votes
2answers
2k views

Should we mock entities and value objects when doing DDD?

After reading a few articles about Newable vs Injectable objects and how these concepts relate to DDD's services, entities and value objects, I was left with some doubts about using newables in my ...
8
votes
2answers
612 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 ...
0
votes
0answers
31 views

Testing a factory service, am I doing it right?

I'm trying to integrate Pagerfanta in my Symfony application, so instead of creating the paginator objects in the controllers, I created an factory for instantiating the Pagerfanta objects: <?php ...
0
votes
0answers
38 views

What to do to during unit testing [duplicate]

I have trouble understanding what to do when unit testing. All over the web I find tutorial for how to use unit testing but it is always just tutorials about how the unit testing tools are working but ...
18
votes
5answers
630 views

Agile without unit tests

Does it make sense to talk about "agile development" or claiming that you are applying an "agile methodology" if the code base you are working on has 0% unit test coverage? (And you, as a team, are ...
0
votes
1answer
83 views

Dependency Injection (DI) and Dependency Inversion Principle (DIP) for built-in functions and external libraries

Question I apologize if this question has already been posted. I tried searching but I couldn't find the answer. I often find myself trying to use DI and DIP where I need to open a file or a socket. ...
0
votes
0answers
52 views

Designing a DOM dependent library

Suppose for fun and learning purpose I need to write a library for forms then, how should I start? to be more descriptive let me summarize my doubts: For beginning I want to restrict myself to just ...
7
votes
3answers
251 views

How to combine strict TDD and DDD?

TDD is about designing code, guided by tests. Thus, typical layers aren't usually built upfront; they should slightly appear through refactoring steps. Domain-driven design involves a lot of ...
3
votes
1answer
122 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 ...
10
votes
3answers
1k views

How to TDD that the correct results are returned

I'm starting a new project, and trying very very hard to use TDD to drive the design. I've been pushing for years, and finally got approval to spend the extra time on this project to use it while I ...
20
votes
6answers
2k views

How to remove a function or feature when using TDD

In texts about TDD I often read about "remove duplication" or "improve readability" during the refactoring step. But what makes me remove an unused function? For example let's say there is a class C ...
2
votes
4answers
151 views

Unit Test for Void which copies data from one location to another

Still learning and getting my head around Unit Testing, (also trying to get into TDD, though I appreciate it isn't the same thing) and in many ways it is changing/improving my code. But I come across ...
5
votes
3answers
185 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 I'...
7
votes
3answers
265 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
113 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 ...
77
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
127 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 input-...
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
681 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
746 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
147 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 ...
94
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
216 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
87 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 https://github.com/CodeAmend/old-...
2
votes
0answers
61 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 ...
80
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
250 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
218 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
185 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
102 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
6k 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
367 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
129 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 ...
15
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
100 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
2k 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
344 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
946 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
862 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
406 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 ...