Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options answers only not deleted user 60357

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.

10 votes
Accepted

Is it good practice to check the requirement multiple times?

Classic TDD suggests writing a single example, then writing the code that makes the example work. … Of course, “real” TDD is not common. Your specific organization might indeed delegate some responsibilities to a dedicated QA role, but that would have nothing to do with TDD itself. …
amon's user avatar
  • 135k
12 votes
Accepted

Introducing TDD in a legacy product

On a social level, it is difficult to enforce TDD. TDD is a possible structure for a personal productivity cycle, and is not really applicable for a whole team. … But this is just about testing, not about TDD. …
amon's user avatar
  • 135k
5 votes

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

In your TDD red–green–refactor cycle, you should add one example data set at a time. Combining multiple test cases into a parametrized test would be part of the refactoring step. …
amon's user avatar
  • 135k
4 votes
Accepted

Xunit TDD - second rule

The flip side of this is that the TDD tests should be created in really small steps as well, so that a tiny change is sufficient to make them pass. … So I would recommend doing micro-TDD as an exercise, not necessarily as part of everyday work. On the other hand, tooling can be improved. …
amon's user avatar
  • 135k
7 votes
Accepted

Where to specify mock behavior in Given-When-then syntax?

The scenario should be set up in the Given step. This involves mocking parts of the system. However, a mock might be used in the When step when that's part of the action. When reading your two scenari …
amon's user avatar
  • 135k
31 votes

Does TDD make defensive programming redundant?

TDD does absolutely not replace defensive programming. Instead, you can use TDD to make sure all defences are in place and work as expected. … In TDD, you are not supposed to write code without writing a test first – follow the red–green–refactor cycle religiously. …
amon's user avatar
  • 135k
7 votes
Accepted

Change-detector tests considered harmful

The code snippet you have shown is an excellent unit test, provided that the unit under test is an abstract part combinator, and does not have a more concrete responsibility within the problem domain …
amon's user avatar
  • 135k
6 votes

Do test-driven and behavior-driven development belong to the "verification" category?

TDD and BDD are not primarily about testing the software, but also about finding out what to build. … For example, the TDD red-green-refactor cycle starts by us thinking about a new atomic requirement for a piece of software, then writing a test case for that requirement, and then implementing it. …
amon's user avatar
  • 135k
33 votes
Accepted

What is black box unit testing?

TDD is neither clearly black-box or white-box. … But when we look at the information flow, TDD tests are not derived from the source code, but from external requirements. Therefore, TDD is more black-box-like. …
amon's user avatar
  • 135k
4 votes
Accepted

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

You don't have to unit-test everything. Relying on integration or E2E tests is fine, especially when the aspect you want to test is at the interface of two components. Here, you have the interface bet …
amon's user avatar
  • 135k
47 votes
Accepted

Why write tests for code that I will refactor?

Refactoring is cleaning up a piece of code (e.g. improving the style, design, or algorithms), without changing (externally visible) behavior. You write tests not to make sure that the code before and …
amon's user avatar
  • 135k
3 votes

Example of writing unit test for a method

Despite the other answers to this question, there is in fact a lot of behaviour in this method, and therefore a lot of things that could go wrong if we don't test them. Here are the cases I would chec …
amon's user avatar
  • 135k
3 votes

Reusing array with static test data across test classes

Tests are code, and as such common best practices should be applied: repeated code should probably be extracted into a method. However, this has to be balanced: Tests should be very, very obvious, m …
amon's user avatar
  • 135k
14 votes

Why is so much attention given to unit testing (TDD) and so little to component level testing

The terms “unit testing” and “component testing” are not defined universally, and different people hold different notions what these terms mean precisely. However, they are generally understood to be …
amon's user avatar
  • 135k
2 votes
Accepted

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

Not all tests are equal. Some have value, and some are a waste of time. Especially for user interface details, it's possible to get carried away and write automated tests where this isn't helpful. H …
amon's user avatar
  • 135k

15 30 50 per page