tdd

Discovering other objects while doing TDD

I am trying to practice TDD. As I understand it, doing TDD should go like this I write a test list for the interface/class I am going to develop. I start with the easiest yet to implement test from my test list. The test gets written, no implementation code yet. The interface of the class gets written to make the code compile. The t...

Should I change the naming convention for my unit tests?

I currently use a simple convention for my unit tests. If I have a class named "EmployeeReader", I create a test class named "EmployeeReader.Tests. I then create all the tests for the class in the test class with names such as: Reading_Valid_Employee_Data_Correctly_Generates_Employee_Object Reading_Missing_Employee_Data_Throws_Invalid_...

How can I easily unit test Blackberry code?

For my university class we are developing a multi-threaded Blackberry application which allows us to scan for other devices running our application with Bluetooth and then transfer files to each-other by TCP over the Wifi interface, implementing NAT traversal, all the while logging our GPS location. (It's a RIM sponsored Computer Network...

Can a test class become a "God object"?

I'm working on a backend for an open source Python ORM. The library includes a set of 450 test cases for each backend, all lumped into one giant test class. To me, that sounds like a lot for one class, but I've never worked on a project that has 450 test cases (I believe this library has ~2000 test cases not including the test cases fo...

Test-First development tool for SQL Server 2005?

For several years I have been using a testing tool called qmTest that allows me to do test-driven database development for some Firebird databases. I write a test for a new feature (table, trigger, stored procedure, etc.) until it fails, then modify the database until the test passes. If necessary, I do more work on the test until it f...

How to use external data in Unit Tests?

I've got lots of unit tests which needs lots of txt, data, html etc. files. Externally storing these files makes life so much easier to update test cases adding new test cases etc. However having dependencies in Unit Tests brings lots of headache in different systems and in different test runners. What are the best practices? Extern...

domain driven design with nhibernate and sql server

I have a reference application that I use to work through DDD issues, and my current focus is on persistence. An alternate title for this post could have been DDD / TDD persistence tools and methods, but that is a (very) broad topic and I do have a specific question on SQL Server. I'm going to outline my current tool set in this paragra...

Is using NUnit's Sequential attribute a valid strategy to achieve one check per test?

Suppose I have several small test cases. Easy enough to setup and easy enough to execute. Suppose each small test case could perform multiple checks. As I buy into the fact that one test case should ideally check one condition, I believe to have a few options to implement such a requirement. Create a base class with all the test cases...

Implement Unit Testing on a legacy web site

Hi All, I downloaded nUnit and TestDriven.net. I have a legacy Web Site application and I would like to implement some unit testing. I created a class in the app_code folder and added Imports NUnit.Framework etc... After writing a basic test, I get the "Can't execute tests in 'Web Site' application." error. I guess the Web Site project i...

Do you check HttpVerbs in your unit tests?

Hi, While looking at the unit tests that come with the standard ASP.MVC Web Project template, I noticed that these do not test whether or not a proper HttpVerbs attribute is set on each action method. It's very easy to test this with reflection, but the question is whether or not it It's worth the effort. Do you check HttpVerbs in you...

Thinking OO with TDD - Where to start?

I'm trying to improve my TDD/OO skills and each time I try and use TDD to influence design I come up against a wall of where to start. Here is my use case/story: Identify a subset of clients that are due for a review. Start a review for them and send out a couple of letters. Now my muscle memory has already opened up a query windo...

Open Source Projects Engineered using TDD and C#?

I'm looking for an example of an open-source project that was engineered using Test Driven Development (TDD) in C# on the .NET Framework. Does anyone know of one? ...

How to implement TDD in ASP.NET WebForms

I know that the reason that Microsoft came out with ASP.NET MVC was to make it simpler to do Test Driven Design (TDD) for ASP.NET. However, I have a rather large brown field (existing) application in ASP.NET WebForms that I would love to implement some TDD type functionality in. I'm assuming that there IS a way to do this, but what are...

Unit testing factory methods which have a concrete class as a return type

So I have a factory class and I'm trying to work out what the unit tests should do. From this question I could verify that the interface returned is of a particular concrete type that I would expect. What should I check for if the factory is returning concrete types (because there is no need - at the moment - for interfaces to be used)...

When to rewrite a code base from scratch

I think back to Joel Spolsky's article about never rewriting code from scratch. To sum up his argument: The code doesn't get rusty, and while it may not look pretty after many maintenance releases, if it works, it works. The end user doens't care how pretty the code is. You can read the article here: Things You Should Never Do I've ...

What should a "unit" be when unit testing?

On Proggit today I was reading the comment thread on a submission entitled, "Why Unit Testing Is A Waste of Time". I'm not really concerned with premise of the article so much as I am with a comment made concerning it: The stem of the problem is that most “units” of code in business software projects are trivial. Change the s...

How to test Model of attached DB in my ASP.NET MVC project?

I created a standard ASP.NET MVC project and then added a SQL Express database in the App_Data folder. The connection string is recorded into the web.config file. I then created a LINQ to SQL data model for the database. I want to test the data model from my Test project but I don't know how to go about this correctly because I am using ...

Excluding code from test coverage

Wherever possible I use TDD: I mock out my interfaces I use IOC so my mocked ojbects can be injected I ensure my tests run and that the coverage increases and I am happy. then... I create derived classes that actually do stuff, like going to a database, or writing to a message queue etc. This is where code coverage decreases - an...

How do I unit test an implementation detail like caching

So I have a class with a method as follows: public class SomeClass { ... private SomeDependency m_dependency; public int DoStuff() { int result = 0; ... int someValue = m_dependency.GrabValue(); ... return result; } } And I've decided that rather than to call m_dependency...

Should a TDD test always fail first?

As a followon to the discussion in the comments of this answer, should a TDD test always be made fail first? Consider the following example. If I am writing an implementation of LinkedHashSet and one test tests that after inserting a duplicate, the original is in the same iteration order as before the insert, I might want to add a separ...