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
-3 votes
0 answers
54 views

Which one of thsese descriptions better describes a correct unit testing? [closed]

EDIT: I don't understand why this question is getting negative votes. To be clear, I'm not asking about your subjective opinion about which approach is better, my question is purely about definition ...
2 votes
2 answers
434 views

How to practice TDD when I constantly need to ditch my current test?

I'm learning and trying TDD recently, and I constantly encounter a situation when I need to ditch my current test because it's too broad. I don't know how to deal with it. To be more specific, let's ...
11 votes
4 answers
2k views

Should you define acceptance tests for vital yet simple behavior?

I'm trying to practice BDD by applying it to a simple problem—in this case, the flocking algorithm, better known as "boids". Before any of the rules (cohesion, alignment, etc.) comes the ...
1 vote
3 answers
407 views

Is low code quality and lack of testing the norm in B2B software development?

I've been working at this company for about a year now. it's a growth company working in B2B. I'm one year out of university, with a major in computer science. I work in the web team, using an Angular ...
1 vote
2 answers
221 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, ...
58 votes
12 answers
6k views

How to test the tests?

We test our code to make it more correct (actually, less likely to be incorrect). However, the tests are also code -- they can also contain errors. And if your tests are buggy, they hardly make your ...
6 votes
4 answers
4k views

Does TDD formally use black box testing to supplement unit tests?

Unit tests are never perfect at capturing functionality, particularly in certain parts of an application (such as the GUI), so everyone needs some measure of black box testing. Does TDD have anything ...
0 votes
1 answer
65 views

Load Testing for Large-Scale Architecture Involving Cloud Servers and Switches

We currently have an architectural setup as described below. Our plan is to conduct a load test, but we face a challenge due to the high cost of real switches. We have two options: either build the ...
1 vote
2 answers
177 views

Can TDD be suitable for a small team with overlapping but not identical domain knowledge

I am trying to get a better understanding of TDD. From a quick google I've found this: In layman’s terms, Test Driven Development (TDD) is a software development practice that focuses on creating ...
53 votes
10 answers
7k views

How should I test "Glue Functions" without testing that "the code I wrote is the code I wrote"?

I usually write my code in a test driven style. I write tests as specifications and then my code. It's great and useful. I always try to ignore implementation when testing and only test behaviour. I ...
43 votes
8 answers
14k 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 ...
0 votes
4 answers
238 views

How to test a service that only connects other services

I'm currently scratching my and my colleagues head about whether and how we could test SyncService::syncFoo in any meaningful way that does not involve basically recreating the whole call tree as ...
50 votes
8 answers
12k views

How do I really write tests without mocking/stubbing?

I have been using TDD when developing some of my side projects and have been loving it. The issue, however, is that stubbing classes for unit tests is a pain and makes you afraid of refactoring. I ...
19 votes
5 answers
5k views

TDD Mock call verification - is it an anti-pattern?

I've been doing TDD for a while now, I feel pretty good about it, I love my test suites and all. However I've noticed that lately I've been doing a lot of mock call verification. For example I'd have ...
1 vote
3 answers
200 views

TDD - What to do when adding a new function on a dependency causes many previous tests to fail?

I was programming today and encountered something that just feels like I'm doing something wrong (maybe?). I've encountered this situation before, but I wanted to reach out and ask if there's a better ...
163 votes
13 answers
37k views

Is there such a thing as having too many unit tests?

I have been tasked with writing unit tests for an existing application. After finishing my first file, I have 717 lines of test code for 419 lines of original code. Is this ratio going to become ...
2 votes
2 answers
418 views

Does the "Pyramid of tests" contradict the idea of tests focusing on behaviour?

I am talking about these two testing strategies : Have a pyramid of tests (with many more unit tests than high-level tests), because high level tests are harder to maintain and slower (see also : ...
-1 votes
3 answers
114 views

Code Coverage and Unit Tests nomenclature [closed]

About tests: I have the following view on nomenclature: Unit tests are the kind of testes where you have a function ExtractBacon, where there is a function with an entry parameter Pig and a return of ...
60 votes
5 answers
35k views

What are the design principles that promote testable code? (designing testable code vs driving design through tests)

Most of the projects that I work on consider development and unit testing in isolation which makes writing unit tests at a later instance a nightmare. My objective is to keep testing in mind during ...
4 votes
4 answers
396 views

How can Behavior-Driven Development be a form of Testing-Driven Development/Unit Testing?

When looking and Behavior-Driven development, "Behavior-driven development is an extension of test-driven development" (From Wikipedia). Researching around various articles, behavior-driven ...
2 votes
3 answers
245 views

Method that returns an object is it adequate for TDD?

Let's suppose I want to follow TDD (Test driven development) and I want to implement a class that is supposed to return a considerable object. It starts to get really complex in my opinion and doesn't ...
142 votes
12 answers
13k views

TDD vs. Productivity

In my current project (a game, in C++), I decided that I would use Test Driven Development 100% during development. In terms of code quality, this has been great. My code has never been so well ...
0 votes
3 answers
221 views

Test driven reduction of technical debt

Suppose you have been put in charge of an already existing project. As you are starting to familiarize yourself with the repository, you notice a few technical debt issues (insufficient test coverage, ...
9 votes
5 answers
3k views

Do test-driven and behavior-driven development belong to the "verification" category?

In university, we were introduced to the two terms "verification" and "validation". The definitions can be summarized as follows: Validation checks that the specifications and ...
5 votes
7 answers
488 views

How to apply TDD to very high level functionality?

Another name for this question could be: How to TDD the main function? My situation: I'm writing a program from scratch that runs a sort of simulation, and I want to apply TDD to the whole development ...
2 votes
2 answers
507 views

Where do unit tests stop and integration tests begin according to the classical school of unit testing?

There are two schools of thought on how unit tests should be written. The first is the Classical/Chicago school, which focuses on the isolation of unit tests, describes a unit as a class or set of ...
40 votes
10 answers
4k views

How baby are your baby-steps in TDD?

Today we were training TDD and found the following point of misunderstanding. The task is for the input "1,2" return sum of numbers which is 3. What I have written (in C#) was: numbers = input.Split(...
38 votes
13 answers
6k 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 ...
13 votes
4 answers
2k views

How should factored-out code be tested as part of the TDD refactoring step?

When in the refactoring step of a TDD process, if we "factor out" some common functionality from two (or more) code modules, how do we avoid that "factored out" code not being ...
46 votes
5 answers
5k views

How do you convince management to "invest" in unit tests?

How did you convince your manager to let you unit test? By "use", I mean being allowed to develop, check-in to source control and maintain the unit tests over time, etc. Typical management ...
2 votes
1 answer
240 views

How to avoid class-proliferation when creating a unit-testable system?

I've been working on a personal project for some time, and I believe that I'm at that point where, if I don't embrace unit tests (and ideally TDD) now, it may be too late, so I want to make the right ...
154 votes
11 answers
24k views

When do you write the "real" code in TDD?

All the examples I've read and seen on training videos have simplistic examples. But what I don't see if how I do the "real" code after I get green. Is this the "Refactor" part? If I have a fairly ...
19 votes
5 answers
1k views

How do you efficiently keep your tests working as you redesign?

A well-tested codebase has a number of benefits, but testing certain aspects of the system results in a codebase that is resistant to some types of change. An example is testing for specific output--...
5 votes
3 answers
5k views

What is recommended way to create test data for unit test cases?

I am new to TDD/unit testing. I am going to write a complex scheduling algorithm in Java. As this module is a core part of our application and there are number of scenarios in it, I want to write ...
158 votes
15 answers
26k 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 ...
1 vote
4 answers
2k views

Should test resource files be stored inside the Java class source directories?

In a TDD (Test-Driven Development)-based Java project built by maven, lots of classes needs to be tested with text-based input files such as .csv. At the beginning, I put them into the src/test/...
2 votes
2 answers
225 views

How would I use TDD / BDD when my webapp interacts with an external REST API?

I'm following roughly the TDD style as explained in the "Obey the Testing Goat" book: You have a functional test for your (Django, in my case) web app that tests the observable behaviour via ...
1 vote
1 answer
235 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 ...
2 votes
5 answers
513 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 ...
34 votes
9 answers
6k views

What are the disadvantages of writing code before writing unit tests?

I have always seen the recommendation that we should first write unit tests and then start writing code. But I feel that going the other way is much more comfortable (for me) - write code and then the ...
1 vote
6 answers
1k views

TDD: testing an abstract class. Test all concrete classes or create mock sub-class to test the behavior?

Well, I'm developing a personal project using TDD and Clean Architecture, and I chose to build an abstract class to gather all use-cases behavior in one single class. My question is: What you think ...
11 votes
9 answers
9k views

Is anyone doing "real" TDD with Visual-C++, and if yes, how do they do it? [closed]

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 (...
5 votes
3 answers
1k views

With Kent Beck's "test && commit || revert" (TCR), do you skip the "red" of "red, green, refactor"?

If you haven't heard of Kent Beck's TCR, it can be summarized with this: any time your tests go green, you commit; anytime your tests go red, you git reset --hard. This post is about how to practice ...
0 votes
0 answers
78 views

Unit test coverage and abundant glue code [duplicate]

How do I solve this riddle of contradicting "good practices" to properly cover my app with unit-tests? These are principles I found about writing unit-tests: Pyramid of testing says unit-...
0 votes
1 answer
393 views

What should I write before the tests in Clean Architecture with TDD?

Well, we all know the main concept of TDD: write a failing test, then implement the testing component to make your test pass. I've been working on a personal project in Clean Architecture following ...
0 votes
1 answer
189 views

Whats a better TDD flow for this problem?

I have a domain entity called a "Booking Window" that has a Start Date and End Date, and defines a period in which a Member can make a Booking.  The business is a mobile car wash, and ...
41 votes
3 answers
7k views

How can I do TDD in real-world applications?

Doing TDD in a kata is simple. A red test, small amount of code, green test, and refactor. Repeat. And that's it. But, I work on a real application. With a REST controller, a service layer for ...
0 votes
4 answers
539 views

Should i write tests if it takes more time than testing manually?

Im making a website and trying to learn Test Driven Development (TDD) I'm doing one of CS50 projects, were we need to make a website to trade stocks. I decided to use this oportunity to learn TDD. I ...
46 votes
9 answers
8k views

Are the tests for test-driven development (TDD) always unit-tests?

I understand test-driven development so far that you are only allowed to write productive code when you have a failing (red) unit test. Based on this I have the question if the test-driven approach ...
0 votes
2 answers
207 views

Is it worth testing simple details? [closed]

In front-end projects(made in frameworks like Angular or React), when we correctly encapsulate complex functionalities, the components that really have some relation to the business logic normally ...

1
2 3 4 5
14