tdd

Best practices for TDD BDD with code that uses external services / api

I'm using a twitter gem which basically accesses twitter and lets me grab tweets, timeline etc. Its really good but I have a lot of my code that uses the stuff it returns and I need to test it. The things the gem returns aren't exactly simple strings, there pretty complex objects (scary as well) so im left scratching my head. So basica...

How to deal with the test data in Junit?

In TDD(Test Driven Development) development process, how to deal with the test data? Assumption that a scenario, parse a log file to get the needed column. For a strong test, How do I prepare the test data? And is it properly for me locate such files to the test class files? ...

Is there a good place to discuss Test Driven Development?

I've just signed up for the Google group entitled Test Driven Development but it's only had 3 posts in 2010 and seems to be littered with spam. Does anyone know of a good TDD focussed place to ask those general perhaps 'subjective' questions which might not be welcomed on SO? ...

Mongomapper - unit testing with shoulda on rails 2.3.5

I'm trying to implement shoulda unit tests on a rails 2.3.5 app using mongomapper. So far I've: Configured a rails app that uses mongomapper (the app works) Added shoulda to my gems, and installed it with rake gems:install Added config.frameworks -= [ :active_record, :active_resource ] to config/environment.rb so ActiveRecord isn't us...

What is your favorite/recommended project structure and file structure for Unit Testing using Boost ?

I have not used Unit Testing so far, and I intend to adopt this procedure. I was impressed by TDD and certainly want to give it a try - I'm almost sure it's the way to go. Boost looks like a good choice, mainly because it's being maintained. With that said, how should I go about implementing a working and elegant file-structure and proj...

TDD with Strategy Pattern

I'm trying to implement the strategy pattern using TDD. Each strategy item implements an interface. What's the best way to do this with TDD? Do you have to create a test fixture for each implementation of the interface testing the same methods but on each implementation? Any articles detailing the approach to take would be gratefully w...

Rails Controller Tests for Captcha using Shoulda, Factory Girl, Mocha

Can someone provide a strategy/code samples/pointers to test Captcha validations + Authlogic using Shoulda, Factory Girl and Mocha? For instance, my UsersController is something like: class UsersController < ApplicationController validates_captcha ... def create ... if captcha_validated? # code to deal with user attributes end ....

Silverlight Unit Testing Framework running tests in external class library

I'm currently looking into different options for unit testing Silverlight applications. One of the frameworks available is the Silverlight Unit Test Framework from Microsoft (developed primary by Jeff Wilcox, http://www.jeff.wilcox.name/2010/05/sl3-utf-bits/). One of the scenarios I'm looking into is running the same tests on both Silve...

When should I opt for test driven development?

My question is same as the title. I have not done Test driven development yet,I have performed unit testing and I am aware of testing in general but I hear it is much advantageous to follow TDD?. So should I opt for it everytime or are there some preconditions... i just need to know some basic or important requirements when i should opt ...

How strict should I be in the "do the simplest thing that could possible work" while doing TDD

For TDD you have to Create a test that fail Do the simplest thing that could possible work to pass the test Add more variants of the test and repeat Refactor when a pattern emerge With this approach you're supposing to cover all the cases ( that comes to my mind at least) but I'm wonder if am I being too strict here and if it is p...

How best to Refactor code that is composed of other private objects that are created in the Constructor

Hi Guys I have the following code that was written without Tests but is actually quite well designed and loosly coupled. The CachedBindingListView constructs a number of objects namely the page provider and the Cache. As Follows. /// <summary> /// Inner data cache /// </summary> private Cache<T> InnerCache { get; set; }...

TDD and UML together

I'm new to TDD approach so I'm wondering if anyone experienced wit this could enlighten me a little. I would like to get some leads how to use UML and TDD methodology together. I've been used to: Design with UML --> Generate skeleton classes (and then keep it synchronized) -> Implement and finally Test. I must admit that testing part wa...

Programmatically execute vim commands?

I'm interested in setting up a TDD environment for developing Vim scripts and rc files. As a simple example, say I want to have vim insert 8 spaces when I press the tab key. I would set up a script that did the following: Launch vim using a sandboxed .vimrc file press i press tab press esc press :w test_out assert that test_out contain...

.NET TDD with a Database and ADO.NET Entity Framework - Integration Tests

Hello, I'm using ADO.NET entity framework, and am using an AdventureWorks database attached to my local database server. For unit testing, what approaches have people taken to work with a database? Obviously, the database has to be in a pre-defined state of change so that the tests can have some isolation from each other... so I need...

How do you unit-test a method with complex input-output

When you have a simple method, like for example sum(int x, int y), it is easy to write unit tests. You can check that method will sum correctly two sample integers, for example 2 + 3 should return 5, then you will check the same for some "extraordinary" numbers, for example negative values and zero. Each of these should be separate unit ...

Howto mix TDD and RAII

I'm trying to make extensive tests for my new project but I have a problem. Basically I want to test MyClass. MyClass makes use of several other class which I don't need/want to do their job for the purpose of the test. So I created mocks (I use gtest and gmock for testing) But MyClass instantiate everything it needs in it's constructo...

Test-driven Development: Writing tests for private / protected variables

I'm learning TDD, and I have a question about private / protected variables. My question is: If a function I want to test is operating on a private variable, how should I test it? Here is the example I'm working with: I have a class called Table that contains an instance variable called internalRepresentation that is a 2D array. I want...

Seeding repository Rhino Mocks

I am embarking upon my first journey of test driven development in C#. To get started I'm using MSTest and Rhino.Mocks. I am attempting to write my first unit tests against my ICustomerRepository. It seems tedious to new up a Customer for each test method. In ruby-on-rails I'd create a seed file and load the customer for each test. It se...

Is there value in unit testing auto implemented properties

It seems exceptionally heavy handed but going by the rule anything publicly available should be tested should auto-implemented properties be tested? Customer Class public class Customer { public string EmailAddr { get; set; } } Tested by [TestClass] public class CustomerTests : TestClassBase { [TestMethod] public void Ca...

What is the purpose of unit testing an interface repository

I am unit testing an ICustomerRepository interface used for retrieving objects of type Customer. As a unit test what value am I gaining by testing the ICustomerRepository in this manner? Under what conditions would the below test fail? For tests of this nature is it advisable to do tests that I know should fail? i.e. look for id 4 when...