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.

0
votes
0answers
11 views

Clean tests in Scala Akka

I am new to Scala and Akka and struggle with testing persistent actors in scala. Right now, we have tests like this (Bank Account example): import akka.actor.ActorSystem import akka.persistence....
119
votes
15answers
18k 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 ...
0
votes
0answers
38 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 ...
37
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 ...
0
votes
0answers
31 views

Development Process for Building Data Intensive Applications

I have been building production ETL applications for the team I am currently part of and the dev process for any given app has been going like: Initial requirements and data Build functional ...
1
vote
1answer
83 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
162 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
485 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
226 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
272 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
114 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
46 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
467 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
224 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
116 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
68 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
86 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
75 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
244 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
155 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
828 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
114 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
136 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
36 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
30 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
354 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
303 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
146 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
131 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
239 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 ...
-2
votes
1answer
159 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
54 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
184 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
181 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
118 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
1answer
142 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
710 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
233 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
129 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
434 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
94 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 ...
2
votes
1answer
129 views

Is it OK to mock or stub libraries in weakly typed languages?

I have quite some experience with TDD in Java and Kotlin and currently try to learn testing with Javascript. I am not sure if this is really a question about weak vs. strong typing or about general ...
-3
votes
1answer
109 views

Unit-testing function with multiple-dependency [closed]

I am trying to test a function that creates a message exchange graph from IRC chat logs. I am having trouble trying to mock the dependencies. The function makes use of util module. The functions ...
0
votes
1answer
146 views

When to use stubs

I'm trying to get into TDD, and a lot of examples sugests that we should use stubs to make our code more flexible. If I'm using javascript (for example) then why should I use stubs, since methods and ...
0
votes
4answers
3k views

Is it really a bad practice to mock a POJO (value object) if you don't care about what it contains?

In the advice of Mockito about how to write good tests, it is written that we should not mock value objects (https://github.com/mockito/mockito/wiki/How-to-write-good-tests#dont-mock-value-objects). ...
5
votes
3answers
2k views

What is black box unit testing?

I recently had my final exam for a software engineering course for my masters program and one of the questions on the exam was the following: Unit Testing is considered: a. White-box Testing b. Black-...