Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

1
vote
4answers
189 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 ...
0
votes
2answers
117 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 ...
0
votes
0answers
4 views

Should my unittest code be much more than my code for a REST API? [migrated]

I am currently developing a Django Rest Framework API with TDD. I have 15 tests and counting for two views, which doesn't seem right to me. It takes me a lot of time to write the tests and a lot of ...
1
vote
4answers
308 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
180 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 ...
-4
votes
1answer
104 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....
0
votes
3answers
127 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 ...
2
votes
2answers
153 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 ...
-2
votes
1answer
75 views

Unit Tests - correct approach to test system with multiple layers

I'm wondering about Unit Tests. Let say i got a code ( in C#, but language is not important here): public class SOT: ISOT { List<string> _internalCollection = new List<string>(); ...
0
votes
1answer
66 views

Should BDD/Gherkin be used only for user visible behaviour?

We're a small team of 3 senior and 1 junior developers and I've been tasked with introducing BDD within our development process. To say there's a lot of confusion about BDD is an understatement and ...
2
votes
2answers
199 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 ...
0
votes
4answers
791 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 ...
16
votes
7answers
4k views

Is it a good idea to write all possible test cases after transforming the team to TDD to achieve a full coverage?

Assume we have a large enterprise-level application without any unit/functional tests. There was no test-driven development process during the development due to very tight deadlines (I know we should ...
0
votes
2answers
211 views

How to unit test device driver initialization?

I am writing an IMU device driver in C using test-driven development methodology. As part of the driver, I pass a struct with user selected configuration settings to an initialization function which ...
4
votes
3answers
239 views

Making pull requests easier to review while practicing XP and refactoring

I practice TDD and refactor aggressively. Recently some colleagues have complained that the resulting pull requests are difficult to review, or would require a lot of regression testing. When I ...
1
vote
1answer
56 views

NUnit specify TestCaseAttribute on implementation or create a test method

Based on this question about the correct usage of nUnit's TestCaseAttribute, I was wondering whether to specify the test case directly on the implementation or create test methods (as when using ...
122
votes
15answers
19k views

How do you write unit tests for code with difficult to predict results?

I frequently work with very numeric / mathematical programs, where the exact result of a function is difficult to predict in advance. In trying to apply TDD with this kind of code, I often find ...
1
vote
0answers
40 views

Unit testing multiple values [duplicate]

If I create a function to calculate the square root of a number, I suppose i should write a single unit test (maybe two, to test how it handles negative numbers). But what if I have a function which ...
38
votes
3answers
5k views

How do integration tests criticize design?

I'm having a read at J.B. Rainsberger's blog post on integrated tests and wonder in which way an integration test is more harsh with our design? We write more integrated tests, which are bigger and ...
1
vote
1answer
88 views

A performant and robust way to reset multiple files to its original state (TDD)

In our automated Java tests, we sometimes encounter issues, such as: Test A creates a custom file A.sh, that is then added on classpath Automated testsuite cleanup does not know about random file A....
2
votes
1answer
199 views

Handling hardware dependency while unit testing

I am writing a driver for an IMU sensor using test driven development approach. Communication protocol of choice is SPI. Using CubeMX and STM32F415 processor, SPI interface is implemented in ...
4
votes
5answers
678 views

Newbie question: 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, ...
1
vote
4answers
315 views

Unit testing Markov chain code

What are the best ways to unit test code that outputs random sequences satisfying specific conditions, such as Markov chains? Let's be specific. There are two natural things to test: That the ...
4
votes
2answers
399 views

TDD for Graphics application

I have googled and read few articles about the TDD for UI. I am not very much clear about how to start the implementation of the Graphics Application using Test Driven Development or how to write unit ...
2
votes
1answer
235 views

How to abstract HAL in embedded test driven development?

Recently I've been reading into topic of test driven development and decided to give it a go with a sensor driver I need. Sensor uses SPI interface and I will implement this driver on STM32F415 ...
2
votes
0answers
50 views

Where in your pipeline does a company that does X+ of deployments per day deal with running E2E/UA Tests [closed]

The ideal goal for my system is the ability to perform an arbitrary number of deployments per day to production while making sure each 'push' goes through the full test suite to make sure it holds up ...
6
votes
6answers
526 views

Is it bad practice to code the solution, then redo in TDD?

I might be wrong, but I feel like the best approach to TDD is Solution, Red, Green, Refactor (adding "Solution" to the standard formula). By coding the solution first, I feel like I am much more ...
0
votes
2answers
555 views

TDD with layered architecture, while only unit testing domain logic

Our project have a lot of layers, Entities Repositories UnitOfWorks Domain Services (Business Logic) Validation Infrastructure Application Services etc.. We are only writing unit tests for ...
1
vote
1answer
184 views

How to unit test high-level abstractions that transform complex Data

I'm practicing unit testing (specifically Test-driven design or Red-Green-Refactor) while writing a recursive descent parser for a simple domain-specific language. In trying to unit test a method that ...
0
votes
1answer
85 views

Client-Side TDD Tests?

More specifically, with regards to ATDD (sort of BDD flavored, or some could argue what was actually intended in the first place by TDD) should be there much UI testing? As I have been testing my UI ...
1
vote
1answer
87 views

Testing Client-Side Code w/o Introducing Brittleness

I'm finding it tough to test my client-side code without testing implementation details. For example, lets say you are testing a login form that displays client-side validation errors and does not ...
1
vote
1answer
89 views

Test RESTful APIs?

When testing RESTful JSON APIs with ATDD/BDD practices in mind is it good practice to test the structure of the response? I'm thinking that it could too easily change, thus making for a brittle test. ...
-3
votes
1answer
72 views

What constitutes AGILITY where Behavior-Driven and Unit Testing are concerned

This morning I had a presentation on PHPSPec which the official website describes as follows: A php toolset to drive emergent design by specification. As defined within an adjective context the ...
1
vote
4answers
267 views

How to prevent implementation/algorithm from leaking into unit tests?

I'm hesitating between algorithm and implementation as most of the questions here on how to prevent coupling between implementation and tests are about using spies/stubs or mocks. The typical problem ...
2
votes
1answer
230 views

Second step of BDD - write “failing scenario step”, does it mean the test for it?

Knowing that BDD somehow avoids using the term "test", I am trying to understand the process as described in a book called The Journey to Enterprise Agility: Systems Thinking and Organizational Legacy....
13
votes
4answers
849 views

How can you TDD for a bug that can only be tested after it has been fixed?

Here's one example: My web application contains draggable elements. When dragging an element, the browser produces a "ghost image". I want to remove the "ghost image" when dragging and I write a test ...
-5
votes
1answer
152 views

TDD the implementation details or behavior only?

When i was developing a console app the algorithm was the following steps: first create a temporary directory then call another command that will create an xml file inside the the temporary ...
0
votes
2answers
145 views

Class design - Inject data or inject repository/service to fetch data?

Let’s say for example I am developing a fictional class called WidgetMaker. If the class depends at some point on lookup data stored in a database is it better to design the class with a dependency ...
-1
votes
1answer
39 views

Testing Application Helper that Depends on Controller

I am working on practicing TDD/BDD/ATDD and I am working on a rails application. I created a helper method that depends conditionally on the type of controller being tested. module ApplicationHelper ...
1
vote
1answer
36 views

Worth it to test client side element presence for web application?

I've really been focusing on making my tests maintainable by focusing on BDD-style tests and only focusing on interfaces. I do not want my tests to be brittle and prevent refactoring. Is it worth it ...
3
votes
8answers
375 views

TDD when testable requirements are hard to come by

I'm in a funny situation. We have a development model that works for an in-house software suite which is focused on responsiveness to the customer. To give you a sense of the environment, when we ...
21
votes
5answers
4k views

Testing a list…All in the same test or one test for each condition?

I'm testing that a function does what expected on a list. So I want to test f(null) -> null f(empty) -> empty f(list with one element) -> list with one element f(list with 2+ elements) -> ...
1
vote
2answers
441 views

TDD workflow with integration testing

I'm having troubles with using the right workflow with TDD. Some people say we should design before writing any code, some say we should make a test, make it pass, then refactor the code and that ...
0
votes
3answers
165 views

How to design a unit test to safeguard against internal state dependency

I'm doing TDD. Let's say I expect some method m of some class C to call some function f (to keep things really simple). How would I design a unit test which would pick-up and therefore fail, if m ...
-3
votes
1answer
140 views

How to find out whether TDD is strictly followed in a project? [closed]

These days we follow TDD across projects in the company. How as a leader I will know whether TDD is truly followed within a project? I would like to achieve this through automation that is instead of ...
8
votes
7answers
1k views

Should I write tests when I can prove code correctness?

People say that "talking about TDD hardly works, if you want to convince someone to TDD, show them results". However, I'm already getting great results without TDD. Showing me that people who use TDD ...
6
votes
1answer
243 views

Can any programming language infer domains of a function from the domains of its input functions?

So I like test-driven development and frequently I have wanted a programming language to assist with the creation of test routines. I have wanted to define the domain of a function and then have ...
-1
votes
1answer
280 views

One Acceptance Test project per layer or one Acceptance Test project per Bounded Context

This link (http://www.taimila.com/blog/ddd-and-testing-strategy/) says: "Feature tests should depend only on the application layer" i.e. presentation layer. I am trying to understand how BDD fits in ...
0
votes
1answer
60 views

Does changing a Specflow scenario after it is written violate the open close principle?

I am trying to learn Specflow. I have bought a book and it arrives at the weekend. Most of the scenarios I see online are for simple things like calculators. For example, please see the scenario ...
3
votes
2answers
254 views

Test Internals with TDD?

I'm new to TDD, and relatively new to software development in general (e.g. < 4 years experience), but I am trying to learn. I have been toying with TDD but ran into what I know realize is a ...