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.

learn more… | top users | synonyms (2)

5
votes
6answers
341 views

I'm confused about which is the correct way to work with TDD

I'm trying to grasp what's the idea behind TDD and how a team is supposed to work with it. I have the following test case with NUnit + Moq (just writing by memory, it is not assured the example ...
6
votes
5answers
503 views

How to do Test Driven Development

I have just 2+ years of experience in application development. In those two years my approach towards development was as following Analyze requirements Identity Core component/Objects, Required ...
0
votes
3answers
115 views

What's the idea behind mocking data access in unit tests [duplicate]

I understand that you're not actually supposed to hit the database or disk when doing unit tests... Why is that? Also, taking something like Moq, what is it actually supposed to mock and where? For ...
2
votes
1answer
264 views

2 questions about TDD

I'm just starting to get to grips with TDD, and I have 2 quick questions; I'm assuming that if I were writing software for a software company, that TDD would work alongside the software design? i.e ...
0
votes
1answer
77 views

More appropriate to validate a dependency filter parameter by mock+stub or by expression compile?

My lead is enforcing TDD on our project. He says he's following Uncle Bob (Robert Martin) and SOLID principles. One of the rules he's reinforcing is what I call "the single cog rule"--there should be ...
4
votes
2answers
251 views

Whose responsibility is it to create the interface and/or acceptance testing? Developer or QA?

I am a backend developer and always create tests for my applications. Recently I study and apply the interface tests (using selenium), but I doubted whether I who should create these tests, developer ...
0
votes
2answers
74 views

Should I put the name of the method I'm testing in the Unit Test method's name/assert message?

Given that a method's name might change in time, is it a good idea to specify the name of the method whose return value I am asserting as a part of the Unit Test method's name? What about the message ...
9
votes
3answers
699 views

In TDD should I have to write Test first or Interface first?

I am learning TDD using c#, as far as I know test should drive the development, that is first write a failing test after write the bare minimum code to pass the test then do refactoring. But it is ...
-1
votes
1answer
90 views

Do you spend your effort to reuse obsolete unit tests or rewrite them entirely? [closed]

I have this javascript project which has a unit test suite(about 200unit tests) that covers about 11.31% of the code that it was testing. The project has evolved greatly but the unit tests where never ...
2
votes
5answers
170 views

TDD: how to test file outputs?

I'm really new to TDD, so I guess this question is pretty basic. We're building a website, and part of the functionality is generating some files (binary files: Excel, PDF, whatever). How should I ...
4
votes
5answers
203 views

If we have TDD and BDD why do we need QA for? [duplicate]

If we have TDD and BDD why do we need QA for? Isn't the job of the developer to write bugs or failing tests? If this is true how a QA fit in? Thanks.
0
votes
0answers
48 views

Mixing newable and injectable in a Callable

I recently read http://misko.hevery.com/2008/09/30/to-new-or-not-to-new/ which discussed newable vs injectable objects. What would you do if you needed to make a Callable that talks to some service ...
1
vote
2answers
139 views

BDD/TDD - exhaustively testing details which are low-level, but still behaviour

We're looking to concentrate more on testing behaviour (as opposed to every class/method individually) in all our automated tests, as espoused by various high-profile online discussions recently. I ...
1
vote
2answers
104 views

In the BDD paradigm why should the “ubiquitous language” be merely semi-formal and not completely formal?

Here's the relevant quote: A common risk with software development includes communication breakdowns between Developers and Business Stakeholders. BDD uses the specification of desired behavior as ...
4
votes
4answers
313 views

Test-Driven Design is not Unit Testing [closed]

Ran across this statement by Martin Fowler circa 2002: Unit testing in XP is often unlike classical unit testing, because in XP you're usually not testing each unit in isolation. You're testing ...
10
votes
1answer
371 views

Testing strategy for games

I've inherited a web-based educational game. Over the past year I've worked towards stabilizing the code and adding new features. Most of the logic is in the front-end, so back-end unit tests, while ...
0
votes
3answers
90 views

Is it anti-pattern to mix unit test and web test? [duplicate]

It is a language agnostic question, e.g. I have a unit test like # Unit test User user = User.create('john'); assertEquals("User name is john", "john", user.getName()); # Web test start from here ...
2
votes
2answers
44 views

Isolated Unit Tests and Fine Grained Failures

One of the reasons often given to write unit tests which mock out all dependencies and are thus completely isolated is to ensure that when a bug exists, only the unit tests for that bug will fail. ...
2
votes
1answer
114 views

How is the correct way of writing TDD for a void API?

Ok so my scenario is this: I have a third party component that offers an API for communicating with an external system. The method calls for commanding the external system to do stuff, all return ...
4
votes
2answers
130 views

Is it ok to write “extra” unit tests?

My understanding of how TDD should work is that you write a failing test for the next bit of functionality you want to add to a function or object, code until the test passes and then write the next ...
5
votes
1answer
152 views

Testing that an attribute does not exist cannot fail when writing tests before code

I have been taught to follow the Red->Greeen->Refactor pattern when doing TDD. There have been situations where this pattern have not been applicable though. For instance, a test to make sure that a ...
0
votes
3answers
185 views

Drawback of using static method [duplicate]

For methods that never access instance variable or static variable and they act just like a function (name-spaced) and they are deterministic base on only the input arguments , I want to ask, are ...
1
vote
1answer
70 views

Question about mocking externals [duplicate]

at company we're developing quite a big project and we're arguing at the testing strategy. The question is: should all of the tests be executed in isolation of external services like database or APIs ...
1
vote
3answers
165 views

Protected variable & protected method in the era of TDD [closed]

I understand protected method is good for unit testing since you can easily mock by the class by overriding the protected method for the sake of testing. However, protected variable is just a global ...
24
votes
6answers
2k views

Sense of unit tests without TDD

We have new (quite big) project starting, that we planned to develop using TDD. The idea of TDD failed (many business and non-business reasons), but right now we have a conversation - should we write ...
0
votes
2answers
70 views

how to write unit test for AND logic gate

I'm learning about unit tests, and have a doubt for a test i want to do, to implement an "AND" logic gate A B A^B 0 0 0 0 1 0 1 0 0 1 1 1 how can i test for a method that works ...
8
votes
2answers
205 views

Test Driven Development for Complex Games

I'm coding a game in my spare time, but I am mostly still a beginner when it comes to programming. I'm sorry if this question is off topic or if it ends up not being helpful to anyone else, but ...
3
votes
4answers
196 views

How to identify and run the most relevant automated tests?

Suppose you have a reasonably large codebase (0.5 - 1 msloc) with a large test-suite (6-7hr single-threaded runtime; with a mix of unit-tests and integration-tests built with different tools). You ...
4
votes
1answer
77 views

Keep or discard tests that use methods now private [duplicate]

When writing object-oriented code from scratch, I try to follow these steps: Write a test that fails. Write a function that makes the test pass. When enough tests and functions are complete, ...
2
votes
1answer
77 views

Wrapping function in closures to make testable functions

In my nodejs project, I have functions like this for socketio. socket.on('draw', function (data) { socket.broadcast.to(socket.room).emit('draw', data); addEvent(socket, ["draw", data]); }); ...
17
votes
4answers
910 views

How can I use unit tests and TDD to test an app that relies mostly on database CRUD operations?

At work, one of my projects is mostly about taking data passed in from an external client and persisting it in a database. It's a Java enterprise app using JPA and most of our logic revolves around ...
2
votes
1answer
224 views

acceptance test driven development in c++

Was put on hold at stack overflow: hopefully it has value here. I want to use a BDD / TDD / ATDD approach in c++. However I really want to emphasize vertical slices of end to end functionality rather ...
1
vote
2answers
73 views

Creating an Interface To a Language's Standard Library?

In the process of learning test-driven development, I've been introduced to dependency injection and the use of interfaces, and have started using these concepts in my own PHP code in order to make it ...
2
votes
2answers
178 views

Relationship between TDD and Software Architecture/Design

I'm new to TDD and have been reading the theory since applying it is more complicated than it sounds when you're learning by yourself. As far as I know, the objective is to write test cases for each ...
0
votes
1answer
97 views

How to unit test models in MVC / MVR app?

I'm building a node.js web app and am trying to do so for the first time in a test driven fashion. I'm using nodeunit for testing, which I find allows me to write tests quickly and painlessly. In this ...
9
votes
3answers
403 views

Designing unit tests for a stateful system

Background Test Driven Development was popularized after I already finished school and in the industry. I am trying to learn it, but some major things still escape me. TDD proponents say lots of ...
0
votes
1answer
109 views

How do you detect lying Stubs/Mocks?

Consider this piece of code from the PHPUnit manual(I'm using PHP only as an example): class StubTest extends PHPUnit_Framework_TestCase { public function testStub() { // Create a ...
3
votes
3answers
135 views

Using 2 Constructors: one that injects dependencies and one that instantiates them

I started using TDD for the first time on a project I started recently. I have a few objects with dependencies and structures that look something like this: public class MyClass { private ...
0
votes
1answer
122 views

Is there a name for this technique in testing? [closed]

When I've written tests for some code and want to make sure that it's actually testing what it's supposed to, I'll mess up or remove the code-under-test, and see if the tests fail. If they don't, I've ...
1
vote
4answers
188 views

Help in ensuring unit tests are meaningful

I've just written a unit test for this function, which loops through a collection of dates and sets properties equal to true or false depending on whether they're before or after a given comparison ...
3
votes
2answers
86 views

How to pick the testing values for parameterized tests for stateless functions?

When writing (parameterized) tests for stateless functions, how do I determine the most ideal set of values to test with? I'm writing a class with mathematical functions in C#, and I want to write ...
2
votes
2answers
260 views

How to know what to test in TDD? [duplicate]

I've heard about TDD more than one year ago, but until now I didn't manage to get myself started with it. Indeed, one of my greatest doubts is always what to test. The examples given always shows test ...
2
votes
3answers
142 views

How to test state of the object

I have a class DataImport with only two public methods public void fromStream(InputStream inputStream); public ImportCommand getImportCommand(); When I test it I send some test data to fromStream ...
2
votes
4answers
186 views

Implementing TDD for existing code [duplicate]

I've just been learning Unit Testing and I'm trying to understand how I could incorporate it with a project with existing code. Say I wanted to write tests for a specific class in that project, but ...
2
votes
2answers
259 views

Testing abstract class' behavior

I'm currently refactoring an existing design, which was created without TDD. There is a class hierarchy with one abstract base class and two subclasses. In the original design, these classes were ...
2
votes
5answers
459 views

DRY code, DRY tests?

At some point I had to create some class "Class1" and that class needs a method "method". So I have the following: Class1MethodTest: A total of N tests that check the behavior of Class1.method Class1 ...
12
votes
5answers
842 views

Types of unit tests based on usefulness

From value point of view I see two groups of unit tests in my practice: Tests that test some non-trivial logic. Writing them (either before implementation or after) reveals some problems/potential ...
1
vote
2answers
956 views

Testing ASP.NET .aspx and .ascx code behind files

I am wondering how to test .aspx.cs and .ascx.cs code behind. Can I use unit testing and if so how? Are there alternatives that will help test the functions in the code behind files? I don't know how ...
4
votes
1answer
271 views

If TDD is design, how do you know your TDD is well designed? [duplicate]

Given a large group (50+) of programmers: All given the same problem, All using Test-Driven Development (TDD), All pair programming, All doing group-based code review, I have personally seen the ...
4
votes
5answers
318 views

Are there any cases when one should not use Test Driven Development? [duplicate]

Is it recommended that TDD be always practiced in a project, or are there cases when it should be avoided? Should we all adopt TDD? Is it standard practice in major software companies?