tdd

information on TAP and TDD for 'C'

I am precisely looking for the info like , TAP is for regression and TDD is for Unit Testing ... or are they mutually exclusive( no need to use both of them ) ? bonus for suggesting 'good' Unit Test Frame work for TDD in C (expecting to address good aspect as well :) ) finally cMockery (googles code) for Testing C code (not derived ...

TDD Anti-patterns catalogue

anti-pattern : there must be at least two key elements present to formally distinguish an actual anti-pattern from a simple bad habit, bad practice, or bad idea: Some repeated pattern of action, process or structure that initially appears to be beneficial, but ultimately produces more bad consequences than beneficial results, and A ref...

Passing web context to a 'service' in ASP MVC app

Hi I'm trying to work out a way of passing the web current http context to a service class (or initialising the class with a reference to it). I am doing this to abstract the rest of the app away from needing to know anything about the http context. I also want the service to be testable using TDD, probably using one of the Mockable f...

How should methods updating database tables be unit tested?

I have an application that is database intensive. Most of the applications methods are updating data in a database. Some calls are wrappers to stored procedures while others perform database updates in-code using 3rd party APIs. What should I be testing in my unit tests? Should I... Test that each method completes without throwin...

Testing Events from Objects

I have been trying to get more in to TDD. Currently keeping it simple with lots of Debug.Asserts in a console application. Part of the tests I wanted to complete was ensuring that events were raised from the object, the correct number of times, since client code will depend on these events. So, I began thinking about how to test the ev...

Is there a difference between TDD and Test First Development (or Test First Programming)?

Both ideas sound very similar to me, but there might be subtle differences or the exact same thing, explained in different ways. What is the relationship between TDD and Test First Development/Programming? ...

IoC & Interfaces Best Practices

I'm experimenting with IoC on my way to TDD by fiddling with an existing project. In a nutshell, my question is this: what are the best practices around IoC when public and non-public methods are of interest? There are two classes: public abstract class ThisThingBase { public virtual void Method1() {} public virtual void Method...

How to test JSON result from Rails functional tests?

As title, I want to assert my AJAX request and test the JSON output, how can I do that? ...

How can I implement TDD in Perl?

We're using mod_perl to produce data in XML and later to be converted into HTML via XSLT, and the database is in MySQL. Our OS is Unix. So I've been reading about how cool and powerful TDD is in .NET, Java with all the available frameworks. I've even tested NUnit before and I kind of like it. You can write the test once and use it prett...

How to MOQ an Indexed property

I am attempting to mock a call to an indexed property. I.e. I would like to moq the following: object result = myDictionaryCollection["SomeKeyValue"]; and also the setter value myDictionaryCollection["SomeKeyValue"] = myNewValue; I am doing this because I need to mock the functionality of a class my app uses. Does anyone know how...

Is there such a thing as excessive unit testing?

I'm not brand new to the concept of unit testing but at the same time I've not yet mastered them either. The one question that has been going through my head recently as I've been writing unit tests while writing my code using the TDD methodology is: to what level should I be testing? Sometimes I wonder if I'm being excessive in the us...

What's a good way to debug unit tests written with multiple [Row] attributes?

When I run the following test in Gallio's Icarus it passes, but when I step into it using TestDriven.NET (Test With->Debugger), it fails because the parameters are not set according to the Row attributes. I was expecting that the method would be called once for each Row attribute applied. What am I doing wrong? If nothing, then what do...

Moq tests using ExpectSet() with It.Is<T>() aren't behaving as... expected.

I've isolated the behaviour into the following test case. I'd be grateful to anyone who can tell me how to expect/verify a property set for a List<T> property - it appears there's something going on inside It.Is<T>(predicate) that isn't making a whole lot of sense to me right now. Sample code will run as a console app from VS2008 - you'l...

TDD Test Refactoring to support MultiThreading

So I'm a newbie to TDD, and I successfully created a nice little sample app using the MVP pattern. The major problem to my current solution is that its blocking the UI thread, So I was trying to setup the Presenter to use the SynchronizationContext.Current, but when I run my tests the SynchronizationContext.Current is null. Presenter B...

TDD - When is it okay to write a non-failing test?

From what I understand, in TDD you have to write a failing test first, then write the code to make it pass, then refactor. But what if your code already accounts for the situation you want to test? For example, lets say I'm TDD'ing a sorting algorithm (this is just hypothetical). I might write unit tests for a couple of cases: input =...

How to create a mock object based on an interface and set a read-only property?

I'm new to TDD. So any help would be appreciated. I'm using NUnit and Rhino mocks. How can I set the ID value to 1 in my mock object? I had a look at this: http://www.iamnotmyself.com/2008/06/26/RhinoMocksAndReadOnlyPropertyInjectionPart2.aspx but the reflection doesn't seem to work against interfaces. public interface IBatchInfo ...

Does TDD apply well when developing an UI?

What are your opinions and experiences regarding using TDD when developing an user interface? I have been pondering about this question for some time now and just can't reach a final decision. We are about to start a Silverlight project, and I checked out the Microsoft Silverlight Unit Test Framework with TDD in mind, but I am not sure ...

How can I unit test my ASP.NET MVC controller that uses FormsAuthentication?

I'm working with a ASP.NET MVC solution in a test driven manner and I want to login a user to my application using forms authentication. The code I would like to end up with in the controller looks something like this: FormsAuthentication.SetAuthCookie(userName, false); My question is how do I write a test to justify this code? Is th...

Using mock objects outside of testing, bad practice?

I'm working on a project where there is a lot of external service messaging. A good way to describe it in only a slightly "hyperbolas" way would be an application where the system has to send messages to the Flicker API, the Facebook API, and the Netflix API. To support disconnected scenarios, logging concerns, developer usability, conf...

How to deal with long running Unit Tests?

I've got about 100 unit tests and with a coverage of %20, which I'm trying to increase the coverage and also this is a project in development so keep adding new tests. Currently running my tests after every build is not feasible they takes about 2 moments. Test Includes: File read from the test folders (data-driven style to simula...