Since I wanted to start this blog, I thought it would be good practice to write the software that runs it
using test-driven development. I've used a bit of TDD recently for additions to existing applications, but
I've not yet started
writing an application using it from beginning to end. I'm getting sick of
eating Italian microwaveable dinners when I have to maintain code. This is my chance to eat something else.
So, without further ado, we'll jump right in.
The first thing I did of course, was to create my directory structure. For the time being, we have:
I like to keep the tests separate from the source. I don't have a reason behind it, other than it helps
keep me a bit organized.
Next, I thought about what a blog needs. We want to deliver items that have the highest business value first,
and move on to things that are lower on the value scale later. In doing this, we get a working application
sooner rather than later, and hence the blog can be used at the earliest possible moment in its development.
With that in mind, we probably shouldn't start with things like
that lets us get included in places like Technorati
you need content to make anything else useful, I thought I'd start with that. Indeed, the
the core part of a blog. Therefore, the first thing I did was create test_PostEntity.cfc under
Now, I'm using CFUnit for my tests, and this assumes you already have it set up. If you need help on
that, you can visit CFUnit on SourceForge
The first thing I do in test_PostEntity.cfc is write
to make sure everything is working:
<cfset assertEquals(expected=4, actual=2+2)>
Next, we need a way to see the status of and run our tests. For this we have test_runner.cfm, which
for the most part just copies what you'll find at the CFUnit site linked above:
<cfset testClasses = ArrayNew(
<!--- Add as many test classes as you would like to the array --->
<cfset suite = CreateObject(
"globalcomponents.net.sourceforge.cfunit.framework.TestSuite").init( testClasses )>
<!DOCTYPE HTML PUBLIC
-//W3C//DTD HTML 4.01 Transitional//EN">
<title>Unit Tests for xorBlog
<h1>xorBlog Unit Tests
Finally, we run that page in a browser to make sure the test runs green - and it does.
Now that we have our test environment set up, we can start writing tests for our
that doesn't yet exist. (To be continued...)
Hey! Why don't you make your life easier and subscribe to the full post
or short blurb RSS feed? I'm so confident you'll love my smelly pasta plate
wisdom that I'm offering a no-strings-attached, lifetime money back guarantee!
Leave a comment
There are no comments for this entry yet.
Leave a comment