2022 Developer Survey is open! Take survey.

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
2 answers
179 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 ...
user avatar
1 vote
2 answers
130 views

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 ...
user avatar
  • 127
0 votes
3 answers
204 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 ...
user avatar
1 vote
3 answers
126 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/...
user avatar
  • 1,467
-4 votes
3 answers
158 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 ...
user avatar
2 votes
3 answers
322 views

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 ...
user avatar
5 votes
2 answers
502 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 ...
user avatar
  • 59
-1 votes
1 answer
127 views

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 ...
user avatar
  • 99
0 votes
3 answers
183 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 ...
user avatar
-2 votes
2 answers
78 views

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 ...
user avatar
  • 113
1 vote
2 answers
282 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 ...
user avatar
  • 129
3 votes
3 answers
266 views

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 ...
user avatar
  • 147
5 votes
3 answers
275 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: ...
user avatar
2 votes
2 answers
218 views

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 ...
user avatar
  • 369
2 votes
2 answers
348 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 ...
user avatar
2 votes
4 answers
246 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 ...
user avatar
2 votes
3 answers
199 views

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 ...
user avatar
  • 668
50 votes
9 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 ...
user avatar
  • 565
3 votes
1 answer
139 views

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 ...
user avatar
  • 149
0 votes
4 answers
226 views

Change architecture design to API to reduce coupling

I was reading articles about TDD and I found the following one. https://blog.cleancoder.com/uncle-bob/2017/03/03/TDD-Harms-Architecture.html In order to answer this question I think someone should ...
user avatar
  • 17
0 votes
1 answer
140 views

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(...
user avatar
1 vote
2 answers
114 views

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 ...
user avatar
  • 129
0 votes
1 answer
196 views

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, ...
user avatar
1 vote
2 answers
91 views

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....
user avatar
  • 31
0 votes
1 answer
87 views

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 ...
user avatar
18 votes
3 answers
2k views

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. ...
user avatar
-4 votes
2 answers
109 views

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"...
user avatar
  • 2,412
6 votes
3 answers
397 views

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 ...
user avatar
0 votes
2 answers
362 views

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 ...
user avatar
-2 votes
3 answers
238 views

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 ...
user avatar
  • 115
-1 votes
1 answer
61 views

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 ...
user avatar
-6 votes
1 answer
139 views

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 ...
user avatar
-1 votes
3 answers
431 views

Should methods with business logic be made private? [duplicate]

So I am writing a project using Spring Boot. All of my logic resides in @Service classes. I have separated each service class based on entity. For example - If I have two independent entities A and B, ...
user avatar
  • 143
1 vote
2 answers
446 views

C++ Organizing classes for easy unit testing (but with some restrictions)

Mild pickle. I have a project which has components that are difficult to test/mock. It might look something like this: class Contenxt; class Server : public SomeOtherClass { public: ServerPlugin(...
user avatar
11 votes
2 answers
2k views

Does TDD contradict the open-closed principle?

My understanding of the TDD methodology is that (failing) test cases are written promptly after finalizing the requirements. My understanding of the open-closed principle (in the context of OOP) is to ...
user avatar
  • 6,715
0 votes
1 answer
210 views

How do I plan my refactor of my android app for better architecture?

The current structure of my app is as follows: One activity and multiple fragments (about 25 fragments) One huge monolithic repository One huge monolithic viewmodel Databinding is being used but with ...
user avatar
0 votes
1 answer
2k views

Test driven development on front end?

When reading through internet, I've seen people are really into testing the front end applications. Some of them also say that they will never hire someone on front end who doesn't have testing ...
user avatar
  • 127
43 votes
7 answers
10k 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 ...
user avatar
  • 668
0 votes
6 answers
306 views

TDD - Make the test work quickly, committing whatever sins necessary in process

Red-Green-Refactor Green stage says, Make the test work quickly, committing whatever sins necessary in process Having an idea of writing a test & make it work quickly, does not look intuitive ...
user avatar
  • 2,225
-1 votes
1 answer
316 views

Is the self-shunt pattern the same as stubbing in TDD?

I am reading the book TDD by Example and one of the patterns demonstrated was the self-shunt pattern. Basically, if I am not mistaken, if I have a test like this: test("list of users should receive ...
user avatar
  • 668
-2 votes
1 answer
55 views

Xunit TDD - second rule

What is the meaning of: You are not allowed to write any more of a unit test than is sufficient to fail; and compilation failures are failure by Robert Martin on TDD? Is it write only the needed ...
user avatar
  • 299
-1 votes
1 answer
172 views

How to do test-driven front end development?

I'm trying to rapidly develop my frontend, but every time I change my code I find myself refreshing my browser and running some macro to test whether the changes in my code solved the problem. I ...
user avatar
  • 115
1 vote
3 answers
256 views

How does TDD behave when the tested unit needs to be expanded?

I want to write some invoicing logic, and I start coding it, using TDD. The following example is silly, but I'm confident it represents well the everyday dilemma I'm facing function ...
user avatar
3 votes
3 answers
429 views

TDD and GIT workflow. How big should branches be?

Let's say we are using TDD while developing some Calculator class (the simplest case - it should provide add, sub, mul and div public methods). We initially start with develop branch. The following ...
user avatar
  • 147
-1 votes
2 answers
87 views

Code Review for Automated Unit Tests [duplicate]

Writing automated unit tests is followed as a part of our development process. We also do have an established code review process for the development code that is written. Should the test code be ...
user avatar
  • 107
1 vote
1 answer
247 views

Persistence layer in the automated testing of an API

The automated tests of an API should be stable and simple. When writing automated tests for an API, we often have to check that the data created with a program implementing this API is persistent. If ...
user avatar
-4 votes
2 answers
260 views

Why use Assertion Library when there is print and console.log?

I'm new to TDD. That begin said, I'm trying to understand why would I have to use assertion library when there is console.log/print? In-fact, I can see more detailed error log thru console.log in ...
user avatar
  • 3
4 votes
3 answers
1k views

Testing unexpected inputs for unit tests and loops?

I'm working on an enterprise that has some Angular/Typescript projects and to avoid repeating code (basically copying and pasting) between them, we decided to go for Monorepo and start write an util ...
user avatar
  • 151
-4 votes
2 answers
60 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 ...
user avatar
  • 1
1 vote
3 answers
232 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 ...
user avatar
  • 1,131

1
2 3 4 5
13