Questions tagged [tdd]

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.

Filter by
Sorted by
Tagged with
2
votes
1answer
235 views

What is the origin of TDD?

I have seen people point me to many different "origins" of TDD. Some will point me to Kent Beck's rediscovery in the late 1990s with XP. Others will mention the 1960s best practice of annotating the ...
-4
votes
2answers
51 views

TDD Implementation

How do you successfully adopt TDD in an organization? Training alone is not enough in my opinion as I feel it requires a change in process and mindset. If TDD has been implemented in your organization ...
2
votes
3answers
101 views

How to write Given/When/Then Scenarios without Given and When being the same

Given that I want to write a Given/When/Then scenario When I write a Given/When/Then scenario Then my Given and When are generally the same thing I've been trying to practice writing user stories in ...
0
votes
1answer
133 views

How to avoid “mock returning mock” when using factory pattern

I have recently encountered multiple articles with title Everytime a mock returns a mock a fairy dies And I ran into exact same situation while using factory class in my code. I am writing a sample ...
4
votes
5answers
1k views

Should all class public methods come from an interface?

I'm currently learning about TDD techniques, one of the suggestion is to test only public methods and skip the private ones. I have also been reading about Mocking. If I want to mock a certain method, ...
5
votes
2answers
741 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 ...
23
votes
7answers
2k views

Does adding unit tests make sense for well-known legacy code?

I'm talking about unit tests in the TDD sense. (Not automated "integration", or what you like to call it tests.) Legacy code as in: (C++) code without tests. (see: Michael Feathers' Working ...
38
votes
7answers
3k views

Unit testing newbie team needs to unit test

I'm working with a new team that has historically not done ANY unit testing. My goal is for the team to eventually employ TDD (Test Driven Development) as their natural process. But since TDD is ...
1
vote
2answers
623 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 ...
16
votes
3answers
4k 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 ...
1
vote
1answer
207 views

Applying BDD accross multiple microservices

I'm involved in a microservices based application. I'm trying to apply the BDD process for this. I need a recommendation how to apply this process correctly given this type of architecture. It is ...
122
votes
14answers
29k views

Why isn't TDD more popular in universities?

Recently, a person here asked a basic question about how to compute in Python all permutations of elements from a list. As for most questions asked by students, I haven't provided the actual source ...
5
votes
3answers
1k views

Tools that can catch “fake coverage”?

Hypothetical scenario: codebase is exercised by unit tests run by a TeamCity build-bot, that also uses the built-in dotCover tool to provide coverage metrics. The build will fail if less than X% of ...
2
votes
3answers
404 views

How to maintain XML/JSON serialization tests?

It is quite common to test JSON / XML producing methods against file-stored expected output (at least in Java world, but probably in other environments, too). For instance there's a method that ...
9
votes
6answers
2k 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) ...
1
vote
3answers
338 views

In TDD, is it bad practice to write helper class for unit tests?

Sometimes when writing a unit test using Test Driven Development (TDD) one may find that checking if the result is the correct one is "more complicated than one line of code", probably deserving its ...
35
votes
10answers
8k views

In TDD, should I add unit tests to refactored code?

While refactoring my code using Test Driven Development (TDD), should I keep making new test cases for the new refactored code I am writing? This question is bases on the following TDD steps: Write ...
1
vote
2answers
131 views

How to convert from TDD scripts to BDD?

There are TDD automation scripts ready and running. TDD tests are written in granular level(class, functions, module) and BDD is written in Behavior level. Is it feasible convert this TDD script to ...
2
votes
3answers
723 views

Whats the difference between tdd and automated tests?

Whats the difference between tdd and automated tests? I'm confused.
106
votes
13answers
25k views

Should I avoid private methods if I perform TDD?

I'm just now learning TDD. It's my understanding that private methods are untestable and shouldn't be worried about because the public API will provide enough information for verifying an object's ...
109
votes
16answers
39k 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 ...
24
votes
6answers
4k views

Whats the real overhead of TDD once the entire team is used to it?

What percentage of time is saved and costed doing TDD. I assume this percentage of cost and reward changes during a projects life-cycle. I'd imagine the initial phase has a lot more cost but little ...
3
votes
3answers
314 views

Writing your test assertions in your function comments (just before the code)?

I'm using PHP and PHPUnit. Something bothers me: the fact that the assertions are in another class (too easy to forget or to ignore, for any new programmer in the project). If the test assertions ...
9
votes
2answers
1k views

Can I start with a passing unit test?

Uncle Bob's rules for TDD are specified here. You are not allowed to write any production code unless it is to make a failing unit test pass. You are not allowed to write any more of a unit test ...
0
votes
1answer
105 views

Does it make sense to write one unit test and loop it through similar components?

I have a situation where I have different forms, each with 4 or 5 steps (components), and I decided to write one unit test per step. After doing it, I noticed they were very similar and I could just ...
5
votes
2answers
968 views

Does a project using proper TDD have a lot of code without tests?

Most (all?) TDD resources show you how the cycle goes: Write Test Check Test Write Production Code Check Test Clean up Production Code Check test They also - to me - seem to imply that all code is ...
1
vote
2answers
62 views

Laravel Controller Testing

This is the first time I tried TDD. At the first time, my controller tests looks like this use RefreshDatabase; class ControllerCustomerIndustryTest extends TestCase { use RefreshDatabase; ...
24
votes
3answers
6k views

Struggling with cyclical dependencies in unit tests

I'm trying to practice TDD, by using it to develop a simple like Bit Vector. I happen to be using Swift, but this is a language-agnostic question. My BitVector is a struct that stores a single UInt64,...
2
votes
3answers
726 views

TDD: Create a Game logic using Test-First Programming

I'm implementing a simple command line game using TDD principles and Unit Testing. My goal is to implement the whole game using Test-First Programming, so every behaviour/class is created from a test. ...
0
votes
1answer
77 views

Is it bad practice to have a helper package in go for testing purposes. Or is this introducing dependence's

I find myself repeating the same code when writing unit tests, for example... When writing functions that work with files, In the setup for the test i often write some code to create a file (in a ...
0
votes
1answer
117 views

How do I test a method which interacts with a database?

So I have a database class which has methods dedicated to specific actions. For example I have below method which accesses and writes to a table in the database: def trackUserPerformance(self, ...
1
vote
4answers
369 views

Is it bad practice to repeat logic being tested in unit tests?

Often I find myself writing a unit test for code and repeating some or a lot of the logic in the unit test to make the unit test DRY. For example, consider the following piece of code: function ...
5
votes
3answers
885 views

Change-detector tests considered harmful

I read this article from the google testing blog. Basically, the idea expressed in the article is that it's a good practice to avoid writing "change-detector tests". This code is given as an example ...
2
votes
4answers
305 views

In TDD, should we specifiy all classes to implement before start coding

My team is interested to apply TDD in our next software project. We have a discussion about how many details should be specified in design specs before the developers start coding. Some of us propose ...
30
votes
8answers
2k views

Is this limitation of Test Driven Development (and Agile in general) practically relevant?

In Test Driven Development (TDD) you start with a suboptimal solution and then iteratively produce better ones by adding test cases and by refactoring. The steps are supposed to be small, meaning that ...
0
votes
2answers
312 views

How to avoid ad hoc constructor for unit testing

According to the answer in this post Should my classes have separate constructors just for unit testing? ad hoc constructor is not good and should be avoided. Unfortunately, I have the same problem ...
4
votes
5answers
2k views

Should you exercise TDD on prototype applications?

I'm developing an iOS app, which is a prototype for a customer. They're expecting it to not be of production standard and are happy for a few rough edges here and there. Since this is my first ...
15
votes
5answers
10k 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 ...
33
votes
8answers
8k 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
4answers
391 views

Is it still TDD if I follow the cycle for each method alone?

The question is not very expressive, anyway what I was wondering is if, if I follow the red-green-refactor cycle for each method is still TDD or if it has to be done globally. I mean, let's say I have ...
1
vote
3answers
204 views

What are the criterion to understand if someone used TDD?

I'm approaching the TDD methodology for software development, reading guides and writing simple applications, because a client of my company wants a software and asked to develop it using TDD ...
57
votes
16answers
7k 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 ...
10
votes
4answers
7k views

What is black box unit testing?

I recently had my final exam for a software engineering course for my masters program and one of the questions on the exam was the following: Unit Testing is considered: a. White-box Testing b. Black-...
3
votes
5answers
414 views

Does not testing internals entail diligent refactoring and/or rely on developer talent?

I'm not asking here what the arguments are for/against testing internal methods (though I'll restate some, and don't mind hearing others). My questions relate to the implications of only testing ...
-3
votes
1answer
1k views

What should I test with unit tests for data access layer? (MongoDB)

I'm working in TDD for my data access layer in MongoDB and I don't know what should I test? I think that I shouldn't test if the queries return what they have to return because It's a MongoDB concern....
1
vote
4answers
1k views

TDD: Uncle Bob's rules versus classic cycle

Uncle Bob says in 'The Clean Coder', chapter 5 'Test Driven Development': You are not allowed to write any production code unless it is to make a failing unit test pass. You are not allowed to ...
7
votes
9answers
3k 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 ...
0
votes
3answers
138 views

Is is worth the time to create a list of manual regression tests for a legacy application?

I am part of a new dev team that is assigned to work on a legacy app. The app currently has no regression or automated unit, integration and system tests. Due to technical debt and convoluted ...
3
votes
1answer
4k views

How to write unit tests for a piece of code that has a data context?

I am new to unit testing and using Microsoft's unit testing library for following piece of code. When I execute the code normally it executes fine, however when I run unit test written for this code I ...
2
votes
2answers
177 views

TDD how to avoid test duplication across team

Our team has decided to develop using BDD/TDD in an effort to become the Agile team we're supposed to be. Vertical slicing appears to be an important part of agile working and gaining the quick ...

1
2 3 4 5
12