tdd

Selling TDD to the team

I have been doing TDD for the past 3 years. We were a small company, and we had very solid support for most aspects of the agile process from management. Everyone on the development team was sold on the process. And thus, the upfront investment it usually takes to build fixtures was accepted knowing it would pay off along the way. (Code ...

Acceptance Tests for Tetris when using Test Driven Development

I want to try to implement the Tetris Game using TDD. From what I've come to understand when reading Growing Object-Oriented Software, Guided by Tests, I should start by defining what would be my Acceptance tests. If I am right, Acceptance tests when doing TDD are defined just like Use Cases. It is of great importance to define a good ...

Refactoring phase of the TDD Traffic Light - how to get this right?

So I made the following test for a class Board that would to be born: [TestMethod] public void Set_The_Origin_As_Violet_And_The_Query_Confirms_It() { Board board = new Board(10, 10); Color expected = Color.Violet; board.SetColorAt(0, 0, expected); Color actual = board.GetColorAt(0, 0); Assert.AreEqual(expected, actu...

How to Test façade classes with no args constructors and no setters with TDD?

This question comes a bit as continuation of the following topic (you don't need to read it, though). It's just a game of Tetris I'm implementing with TDD. So here is the problem: I have a set of Acceptance tests. I have defined the following test in one of them: [TestMethod] public void I_Can_Query_Any_Piece_Of_The_Board_For_A_Color()...

When having to do a design change, should I change the already working tests first and only then try to run the new one?

I have a bunch of tests that assume that my Tetris class is composed by a Board class. I now feel that instead of having a Board inside of that Tetris class, what I will want is to have a Board inside a BoardEngine class that is inside the Tetris class. That is what this test is asking for: [TestMethod] public void Start_Game_An...

tdd with non-trivial algorithms

Hi there, In these days I'm coding some data structures in Java. Many of them (if not all) offer a very simple interface (add, contains, delete) but under the hood there are non-trivial algorithms. How can I use the tdd technique in such a situation? I think that the problem is that tdd (and in general unit testing) is about testing t...

Unit testing when developing a website?

After learning about TDD and unit testing, I'm really looking to write tests when I code, preferably before I code because I see the benefits coding in Python. I'm developing a website, and I'm trying to write tests according to the requirements, but its proving more difficult than expected. I can see the benefits of writing tests when ...

Testing a method called many times in moq

I have an interface like so: Interface IWriteFile { string FileName {get;set;} void Open(); void WriteData(string dataToWrite); void Close(); } I want to test a class that will use this interface to populate a file. It will be calling WriteData a bunch of times and I just want to test the final output. Is there a way to intr...

ATDD versus BDD and the proper use of a framework

I am just getting into the concept of BDD and have listened to Scott Bellware's talk with the Herding Code guys. I have been playing around with SpecFlow some and like it pretty well. I understand the distinction between ATDD and TDD as described in the blog post Classifying BDD Tools (Unit-Test-Driven vs. Acceptance Test Driven) and a...

Static dependency exit strategy

The project that I have just joined uses the command pattern quite extensively for handling calls into the business logic layers of the project. The business logic layers are built as static handlers calling into providers. The commands then call into these static handlers. The team want to improve test coverage, and I would like us t...

Can units tests be implemented effectively with agile development?

Soon I will be involved in a project that will be using the agile project management/development approach, with 5 (or so) 2 week sprints. The project will be using a DDD design pattern which I have found in the past works great with unit testing, hence I have enthusiasim to use it for this project as well. The only problem is given the f...

A programming language designed to be testable

Does anyone know of a programming language that is testable by design or at least exhibit very good properties in terms of testability? For instance, a programming language designed so that unit testing is a non optional part of the coding process, or, better yet, a programming language where the program is more or less inferred from th...

First TDD test with no assert/expected exception. Is it worth it?

Let's say I'm starting to do a game with TDD. Is this a good first test? [TestMethod] public void Can_Start_And_End_Game() { Tetris tetris = new Tetris(); tetris.Start(); tetris.End(); } It basically forces me to define 3 things: the Tetris class and its Start() and End() methods, but besides that it's pretty useless. It m...

How do I unit-test saving file to the disk?

I know that it's strongly recommended to run unit-tests in separation from file system, because if you do touch file system in your test, you also test file system itself. OK, that's reasonable. My question is, if I want to test file saving to the disk, what do I do? As with database, I separate an interface that is responsible for datab...

Handling Async With Specflow for Silverlight

The Silverlight Unit test Framework defines a process for dealing with Async calls (derive test class from Microsoft.Silverlight.Testing.SilverlightTest, add Asynchronous attribute, use EnqueueXXX methods.) Considering the separation that SpecFlow presents between the test class and the steps: Can these tools be brought to bear to wai...

TDD in Ruby on Rails?

I wonder how TDD is done in Rails. Here are the steps I have written down: Create migrations and models for the database tables Add associations to the models Write unit tests for the models and run and see them fail Add validations to the models Run tests and see them pass, if not, edit the code till they pass Create routing, control...

TDD vs BDD in Rails 3?

Im a beginner when it comes to TDD and BDD. This is what I know: To use TDD in Rails I use it's built-in unit-, functional and integration tests. To use BDD in Rails I use Cucumber. So are these two different techniques that shouldn't be used together? If I use TDD, then I shouldn't use BBD/Cucumber and vice versa? Please enlighten...

Extracting class when TDD'ing. How to test the new extracted class?

So I had a couple of methods in my main class that used a matrix to set pixels on or off. I got all my current tests running and so, and I've decided it's already time to pull out some of that logic related to the matrix and such and create a Matrix class. My question is, besides the tests I currently have for my SUT class (I'm just in ...

Ideas on how to TDD application that needs to retrieve user name from system environment

How do you typically TDD aspects of your application that need to access operating system's system variables? For example, my application needs to be able to correctly retrieve the operating system's currently-logged-in user name. So I TDD a function that does this, and it's called: string getUserNameFromSystemEnvironment(); The p...

How to configure Cruise Control.Net to show proper error in Web Dashboard?

We have setup Cruise Control.Net to build .Net projects from source control. Problem is that when the build fails the error log shows a huge build xml and we struggle to find out the actual error. How to configure Cruise Control to show error in more readable format? ...