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
0 votes
4 answers

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 ...
gries's user avatar
  • 239
1 vote
3 answers

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 ...
jrgilman's user avatar
  • 121
-1 votes
3 answers

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 ...
sergiol's user avatar
  • 157
2 votes
2 answers

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 : ...
Tristan's user avatar
  • 207
0 votes
3 answers

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, ...
EdG's user avatar
  • 11
2 votes
3 answers

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 ...
Nmaster88's user avatar
  • 167
9 votes
5 answers

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 ...
BenjyTec's user avatar
  • 201
5 votes
7 answers

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 ...
charlieshades's user avatar
2 votes
2 answers

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 ...
B-Rad's user avatar
  • 203
13 votes
4 answers

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 ...
Rob Gilton's user avatar
2 votes
1 answer

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 ...
Pablo's user avatar
  • 29
2 votes
2 answers

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 ...
Lagerbaer's user avatar
  • 526
1 vote
6 answers

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 ...
Gabriel Antonio's user avatar
0 votes
0 answers

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-...
Gherman's user avatar
  • 945
0 votes
1 answer

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 ...
Gabriel Antonio's user avatar
0 votes
1 answer

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 ...
Mike Hogan's user avatar
0 votes
4 answers

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 ...
Portho Games BR's user avatar
41 votes
3 answers

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 ...
fluminis's user avatar
  • 573
0 votes
2 answers

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 ...
Vitor Figueredo Marques's user avatar
3 votes
2 answers

In TDD, should a CLI menu be tested?

I have to create a CLI application following TDD. The app should present a menu of items that can be added to an internal structure, and process those items according some rules. My question is if I ...
Allonsy's user avatar
  • 147
0 votes
3 answers

How should you start applying TDD in a clean architecture?

I'll be using Uncle Bob's terms, so i'll call the use cases "interactors" and the domain entities "entities". As far as I understand, the most specific business rules that are most ...
Jordi Pagès's user avatar
1 vote
4 answers

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/...
Rui's user avatar
  • 1,569
-4 votes
3 answers

is it bad practise to go back to your last backup when you encounter an unneccessary bug? [closed]

I find when I am programming and I fix a bug in one area of the codebase, sometimes something slightly related or maybe unrelated breaks, and as a result I usually copy and paste the fix to a ...
jackw11111's user avatar
2 votes
3 answers

Is it good practice to check the requirement multiple times?

When writing tests for TDD is it good (or bad) practice to write multiple test for the same requirement ? If it's good how many times should it be repeated? If it's bad is it it the QA engineers work ...
Dhanushka Amarakoon's user avatar
5 votes
2 answers

Should you write unit tests for templates and frameworks, such as in .NET?

How much (if any) unit tests should be written when you start a new templated project? In particular, let's take as an example a typical .net framework template for mvc or other similare ones ...
Erik Mm's user avatar
  • 59
-1 votes
1 answer

Checking a related aggregate existence is Domain concern?

This is my specific situation: I am following DDD and Event sourcing to implement my application (using C#). I have a Domain layer that contains Aggregates' implementation. I write unit tests for this ...
Mehrdad's user avatar
  • 99
0 votes
3 answers

Should test cases show desired behavior or actual/current behavior, or can they do both?

Let's say I want to add tests to a software that has some flaws/bugs. I want to add the tests before I fix the bugs. And I want to actually merge them in the main branch, not just have them in a ...
donquixote's user avatar
-2 votes
2 answers

Should application state be tested when testing Api?

I am trying to adpot a TDD process. I am a bit confused when it comes to testing an Api. I know for sure that the status and the response should be tested. But I am thinking if whether or not I should ...
Rami ZK's user avatar
  • 113
1 vote
2 answers

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 ...
Searene's user avatar
  • 129
3 votes
3 answers

TDD and Unit Testing for new code, but existing patterns

How should I go about using TDD and writing tests in this scenario? Suppose we have request handler classes. In short, a handler applies a "request" (e.g. Update details) to an entity then ...
ilitirit's user avatar
  • 147
5 votes
3 answers

Where to specify mock behavior in Given-When-then syntax?

I am unsure where/how to specify the behavior of a mock in a test scenario when using the Given-When-Then syntax. It seems to me both Given and When could be correct. Consider the following example: ...
slingeraap's user avatar
2 votes
2 answers

Testing edge cases in TDD? [duplicate]

When doing TDD "by the book" we should only -- as far as I understand -- write failing tests. This means tests for unimplemented functionality. I often find myself wanting to add tests for ...
kqr's user avatar
  • 369
4 votes
3 answers

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 ...
Daniel Kaplan's user avatar
4 votes
4 answers

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 ...
Dane Bouchie's user avatar
2 votes
3 answers

Given a function that has already been unit tested, but is present in another unit, should I bother testing it again?

Say, for instance, I have this simple function in my domain layer: function canCreateNewUsers (principal: User): boolean { return principal.isSuperAdmin || principal.isAdmin // || ... a bunch of ...
kibe's user avatar
  • 738
50 votes
9 answers

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 ...
Derek C.'s user avatar
  • 573
3 votes
1 answer

Simulation Testing: how to test something that depends on its previous state

I'm practicing test driven development while implementing a network simulator: devices communicate with each other and implement little bits of functionality that respond to messages. Each device has ...
Mrwerdo's user avatar
  • 149
0 votes
4 answers

Change architecture design to API to reduce coupling

I was reading articles about TDD and I found the following one. In order to answer this question I think someone should ...
Rauuuñ's user avatar
  • 17
1 vote
1 answer

How to write tests in TDD for downloading and unpacking a file?

So I want to write this function that downloads a file and unpacks it in python using TDD. The function will look like this approximately import urllib.request import tarfile def download_and_unpack(...
Martin Raspaud's user avatar
1 vote
2 answers

Best Practice: Unit test coverage vs. in-method sanity checks [duplicate]

I have a code-coverage requirement of of a certain percentage, and face the following tradeoff: Should I sacrifice in-method sanity checks and error handling for ease of (unit-) testability? Lets ...
MPIchael's user avatar
  • 219
0 votes
1 answer

How to make the tests run faster?

I develop my current project with a very strict approach to TDD and try to make it as close to Kent Beck's TDD By Example book. So right now I've got code coverage of 93%, with 1290 unit test cases, ...
Bawenang Rukmoko Pardian Putra's user avatar
1 vote
2 answers

Mock part of a static method

I am designing a test for an existing static method: public static boolean hasPermissions(String username, int pageid) { PermissionsService s = new PermissionsService(); int[] pages = s....
Zort's user avatar
  • 31
0 votes
1 answer

Direct communication between message-driven bounded context

My project comprises of serveral bounded context which communicate with each other with RabbitMQ The front end of the project is written in C# and the backend is in Java. The RabbitMQ communication ...
Nishant123's user avatar
19 votes
3 answers

How do you push Design changes in TDD in late development stage

I was recently part of a TDD development team. At certain point I realized that there is a design mistake instead of Object Oriented Design and Structural design the problems were solved via statuses. ...
Alexander Petrov's user avatar
-4 votes
2 answers

What is the most complete way to test an imperative function?

What is the most complete way to test an imperative function? By "complete" I mean, something that is robust, that tests all the edge cases of the function, that so much as "proves"...
Lance's user avatar
  • 2,561
7 votes
3 answers

Is there a logical complexity beyond which TDD doesn't work?

All the books which talk about test-driven development (TDD) illustrate it with only very basic examples, less than 100 LOC. The algorithms I wrote using TDD were larger, but still relatively small in ...
Arseni Mourzenko's user avatar
0 votes
2 answers

How to write the test for a class function which depends on another function to be tested in TDD approach?

I have a class class A { List<int> a; A() { this.a = []; } void add(int x) { a.append(x) } List<int> display() { return a; } } This is a simple class I want to ...
rahul  Kushwaha's user avatar
-2 votes
3 answers

Can TDD and White-box testing be combined directly?

I am getting started with software testing in Java and was wondering if test-driven dev and white-box testing could be combined directly... If not, what ways can we extend TDD to combine white box ...
tavalendo's user avatar
  • 115
-1 votes
1 answer

Properly testing UI presenters without duplicating tests of subcomponents

I am writing the embedded firmware for an effect pedal. The pedal's ui consists of a few knobs a few buttons and a few leds and it consists of various control modes each corresponding to a seperate ...
Liarokapis Alexandros's user avatar
-6 votes
1 answer

Why is automatically generating automated tests frowned upon?

First, the most obvious grouse someone has against this I can think of is the intricacies of an actual method. It's not enough to merely ensure no errors are thrown. Functions usually contain ...
I Want Answers's user avatar

2 3 4 5