Stack Exchange Network

Stack Exchange network consists of 174 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.

5
votes
3answers
178 views

How to run long (>10 hours running time) verification test for continuous integration of scientific software

This question continues on a previous question asked here about continuous integration for scientific software. Like the poster of that question, I am developing software for numerical simulations and ...
1
vote
2answers
123 views

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

I am new to TDD/unit testing. I am going to write one complex scheduling algorithm in Java. As this module is core part of our application and there are number of scenarios in it, I want to write ...
0
votes
4answers
507 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 transform 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
106 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
206 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
31 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
84 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
167 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
520 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
246 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
298 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
148 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
47 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
486 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
336 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
140 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
72 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
77 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
70 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
254 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
171 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
829 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 ...
-4
votes
1answer
129 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
141 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
38 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
33 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 ...
2
votes
8answers
358 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
3k 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
360 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
150 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
134 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
240 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
208 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
56 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
208 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 ...
0
votes
0answers
72 views

Requiring developers to unit test their code [duplicate]

I work at a small company, and I am tasked with designing a good policy regarding TDD and unit testing that encourages developers to write unit tests. As of now, I am the only developer who ...
3
votes
3answers
197 views

How do you structure test cases on objects with multiple degrees of freedom?

I am test driving a method which is parameterized by two inputs and depends on a Strategy. Here's what I have: [TestCase(input_a1, input_b1, strategy1)] [TestCase(input_a2, input_b1, strategy1)] [...
1
vote
2answers
134 views

Should I write integration test that test my code with real-network servers, before I start writing my code?

I am trying to write integration tests for a client-server app. The client app runs on a user's machine and connects to the server app running on a specific Windows server, network-serverA. The ...
2
votes
2answers
184 views

Why does BDD advise an outward in approach to testing?

I am trying to decide whether BDD is suitable for my project or not. I was reading about BDD here: https://en.wikipedia.org/wiki/Behavior-driven_development and here: https://agilewarrior.wordpress....
2
votes
3answers
866 views

Is there a need for an IoC container in TDD unit tests?

While I do see the benefits of IoC containers (as I've used them a fair bit), I don't see how they can be incorporated within TDD unit tests (note, I'm only interested in unit tests here, not ...
1
vote
2answers
241 views

Does it matter how I setup test data when creating unit tests?

I have a unit test similar to the code snippet below, it should check that the AddUser method only allows unique emails. My question is around the Arrange part of this unit test, I use existing ...
2
votes
3answers
132 views

Using methods that are not under test within a unit test for a different method?

I'm building a Sudoku generator. I have a board class with a number of methods: public class Board { public Board() { /* Creates an empty board */ } public bool ValidateRow(int row) { /* ...
1
vote
1answer
557 views

What are TDD and integration test naming conventions?

I am building a small web API using .NET Core. I want to practice TDD and this is my first attempt at TDD. These are a few use cases of the API: Users in administrator role can create/edit/delete ...
-2
votes
1answer
95 views

Android testing, what to test? [closed]

I'm quite a noob in the world of testing. I've read all the materials related to Android testing: Unit test Instrumentation test JUnit Robolectric Espresso etc. The thing is that, all the examples ...