« Change an Organization Like a Startup?| Main | The Hat »

Setting up F# for TDD with xUnit

| | Comments (0)

"You've got to be very careful if you don't know where you are going, because you might not get there. " - Yogi Berra

Some things are so easy they're idiot-proof, but then along comes a better idiot to prove you wrong.

I was thinking about this today as I set up Visual Studio, F#, and Xunit

Since I thrashed around for about an hour and shouldn't have, I thought I would make an easy 1-2-3 cookbook for setting up F# and TDD.

Step 1: Download the latest version of XUnit


I prefer XUnit.NET over NUnit




Step 2: Create a new F# Application


If you're following along at home, you'll need to
go to Microsoft to get F# if you haven't already



Step 3: Add a file to put your tests in (not strictly necessary)


Separating tests and the rest of your code is just good practice



Step 4: Add a reference to the XUnit dll


It's a small file, weighing in around 64K



Step 5: Setup the hotkeys and external tool item for xUnit


Good use of hotkeys and macros make coding faster.
It's the little stuff like this that adds up over time



Step 6: Write the shell of the method you're starting


Even with test-first, you gotta have something to bounce your tests off




Step 7: Write your tests


I like the xUnit syntax and structure much better than NUnit's verbosity



Step 8: Code!



I had a little problem with the dlls not copying over to the right folder, so I manually copied them. Actually I just dumped the whole xUnit directory over into my build area. I also thrashed around with making my tests public, but it wasn't necessary. Using the output window is an okay way of getting results, but I like big green lights when I code, so the xUnit GUI is more my speed.

I also had to explicitly include both XUnit and the program file at the top of the tests file. F# is sensitive to compile order and indentations -- easy to get stalled a little when picking it up after a break.

There -- next time should be a lot easier!

Leave a comment

About this Entry

This page contains a single entry by DanielBMarkham published on September 3, 2009 10:48 PM.

Change an Organization Like a Startup? was the previous entry in this blog.

The Hat is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Social Widgets





Share Bookmark this on Delicious

Information you might find handy
(other sites I have worked on)





Recently I created a list of books that hackers recommend to each other -- what are the books super hackers use to help guide them form their own startups and make millions? hn-books might be a site you'd like to check out.
On the low-end of the spectrum, I realized that a lot of people have problems logging into Facebook, of all things. So I created a micro-site to help folks learn how to log-in correctly, and to share various funny pictures and such that folks might like to share with their friends. It's called (appropriately enough) facebook login help