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.
678 questions
1
vote
1
answer
106
views
How should I design a password reset flow when the PasswordService depends on UserRepository (email vs ID)?
I’m working on a three layers architecture backend (Laravel).
Here’s the context:
I have a PasswordService responsible for updating a user’s
password.
and a Otpservice responsible for verifying/...
3
votes
2
answers
233
views
Ensuring unit test data stays accurate
Say I have a method that expects data to be in some form to perform accurately. In the actual service/application flow, that data is formed upstream in other methods or services. How can I ensure the ...
0
votes
4
answers
233
views
Avoid Test duplication if a function created via TDD has an implementation detail that is later used in other functions
Lets say I have an API with two functions:
CreateNewMachine(CreateMachineCommand createMachine);
EditExistingMachine(EditMachineCommand editMachine);
The internal logic of both functions should be ...
1
vote
1
answer
176
views
NUnit testOf attribute usage
What are the use cases of TestOf? I'm new to NUnit testing and from what I have seen, most people don't use this attribute that much.
From my experience, TestOf helped me to quickly identify what ...
0
votes
4
answers
335
views
TDD and code reusability
Let's say that I've been iterating over my feature A with TDD. After several red-green-refactor cycles, I ended up with a nicely polished implementation with a part of the SUT encapsulated into some ...
0
votes
2
answers
2k
views
Setting up private properties for unit testing
I'm doing some TDD practice for my own learning.
I'm trying to figure out how to transparently set up private properties of an object to support testing.
I have a binary tree node:
internal class Node ...
38
votes
12
answers
8k
views
How do unit tests facilitate refactoring without introducing regressions?
We all know the standard TDD cycle: I first write a unit test, the smallest unit test that fails; then I write some production code, again the smallest amount of production code that is sufficient to ...
11
votes
4
answers
3k
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
1
answer
78
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 ...
0
votes
4
answers
534
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 ...
-1
votes
3
answers
138
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 ...
0
votes
3
answers
296
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 ...
2
votes
2
answers
835
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 ...
2
votes
1
answer
388
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 ...
2
votes
6
answers
4k
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 ...
0
votes
1
answer
459
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
4
answers
849
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 ...
0
votes
2
answers
227
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
vote
3
answers
2k
views
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 ...
-4
votes
3
answers
219
views
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 ...
5
votes
2
answers
780
views
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 asp.net mvc or other similare ones ...
2
votes
5
answers
957
views
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 ...
2
votes
2
answers
472
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 ...
5
votes
3
answers
1k
views
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:
...