Project update

It's been for ever and a day, since I have done any commits to this project, but prompted by Janet's comments I have made a handful of commits to the repository.

  1. cfUnit is now supported
  2. A fix for cfmx 6.1 and recursive directory lookups
  3. The code can now handle missing tearDown methods in existing test cfcs.

I have also tried to simplify the config.xml file a little and here's what the default looks like:

<stubbie>

   <config>
      <appName value="myMapping" /><!-- the name of your app, can be the mapping name as set up in cfadmin -->
      <appPath value="/my/full/path/to/the code/" /><!--full path to the app -->
      <packageRoot value="" /><!-- if you have a mapping for your app's cfcs, e.g. com.mydomain, specify it here (if you have specified an app name the result will be com.mydomain.myapp) -->
      <saveTestFilesTo value="" /><!-- Not implemented yet, optional storage location for the test stubs -->
      <unitTestFramework value="cfcUnit"/><!-- cfcUnit/cfUnit -->
      <coldSpring use="false" path="config/cs.xml"/><!-- (working on it) whether or not to use CS and if so where is the cs config file in relation to the app path -->
   </config>
   
</stubbie>

But a concrete example usually works best, so:

<stubbie>

   <config>
      <appName value="art" /><!-- the name of your app, can be the mapping name as set up in cfadmin -->
      <appPath value="/Users/gregstewart/Sites/Client X sites/Fusebox/ART2/" /><!--full path to the app -->
      <packageRoot value="" /><!-- if you have a mapping for your app's cfcs, e.g. com.mydomain, specify it here (if you have specified an app name the result will be com.mydomain.myapp) -->
      <saveTestFilesTo value="" /><!-- Not implemented yet, optional storage location for the test stubs -->
      <unitTestFramework value="cfcUnit"/><!-- cfcUnit/cfUnit -->
      <coldSpring use="false" path="config/cs.xml"/><!-- (working on it) whether or not to use CS and if so where is the cs config file in relation to the app path -->
   </config>
   
</stubbie>

appName : This now refers to a cf mapping in the administrator for my project, in this case art, however if you are using a package approach (with say a value of "com.domain"), then this value would simply be appended to the packageRoot (e.g. com.domain.art)

appPath : This is now the full path to the application, e.g. on my local machine /Users/gregstewart/Sites/Client X sites/Fusebox/ART2/

packageRoot : Hasn't changed

saveTestFilesTo : Hasn't changed

unitTestFramework : Now supports cfUnit.

coldSpring : Something working on, i.e. use ColdSpring to generate mock objects. Could be ages before it sees the light of day, if my past track record is anything to go by.

Thoughts and suggestions are still most welcome!

Wikipedia's TDD entry

Wikipedia's page on Test-Driven development (TDD), provides an excellent overview of the purpose of TDD, it's advantages and shortcomings.

More unit testing generator projects

Finally managed to catch up on a few blog posts this week after another project deadline has passed and I came across two more projects that have started to generate unit tests for you:

Both projects do a hell of a lot more than just create test objects though. Definitely worth checking out.

For those 11 folks...

...who so far downloaded the code. I'd be pleased to hear from you, if you have had a chance to install it and run it. I am especially interested in the experience so far, any issues, such as unclear install instructions, config problems, calling the CFC and of course any bugs.

Feel free to comment here, use the forums or even log an issue with the tracker!

Subversion repository is available

I finally got round to setting up the Subversion (SVN) repository today. So if you feel like living dangerously you can grab the source from SVN trunk.

Installing and using Stubbie

I thought it would also be useful if I post the installation and usage instructions here.

Installation

The simplest way to install stubbie is to just place it in your webroot, alternatively you can just create a mapping called /stubbie and point it to your install folder.

Usage

Using stubbie requires 2 steps the first is editing config.xml and the second is calling the component.

Step 1 Open up the config.xml file and edit it the following settings

<stubbie>

   <config>
      <appName value="myAppName" /><!-- the name of your app, e.g. the folder name under which the app resides, used to suffix the root path of your app -->
      <appPath value="/Full/Path/To/Root/Of/Your/App" /><!-- full path to the app, minus the app folder name -->
      <packageRoot value="com.myDomain" /><!-- if you have a mapping for your app's cfcs, e.g. com.mydomain, specify it here -->
      <saveTestFilesTo value="" /><!-- Not implemented yet, optional storage location for the test stubs -->
      <unitTestFramework value="cfcUnit"/><!-- cfcUnit and cfUnit are allowed options here -->
   </config>
   
</stubbie>

Step 2

Place the following code anywhere you wish to invoke stubbie from:

<cfset configFilePath = ExpandPath("./config.xml")/>

<cfset stubbie = CreateObject("component","Stubbie").init(configFilePath)/>
<cfset stubbie.build()/>

Download Stubbie

Version 0.1 is available for download. I'd like to call this the "I am working release, but it's all a little messy" release. There are a ton of improvements to be made and still a few features I'd like to add, but it's working and figured this was a good time to put the code out there and get some feedback.

Feel free to report any issues, feedback and suggestions.

Welcome to Stubbie project blog

I hope that people will find this project useful in their day to day development.

So what is Stubbie? The short and sweet is: it creates a set of test stub objects to be used in your unit tests based on your projects CFCs.

Slightly more protracted: Stubbie was inspired by a feature in Rails that creates stub test objects based on objects found in your application.

You can run Stubbie standalone or as a plugin (there is a Mach-ii plugin available) and on execution it will recursively examine your projects code for CFCs and generate generic test objects for you, as well as a Test Suite. No more excuses to not use Unit Testing.

It currently supports both CFUnit and CFCUnit.

It's all a bit slap dash right now, but I hope to tidy things up in the near future (and actually upload some code for you to download). Of course feedback, critiques and suggestions are always welcome.

BlogCFC was created by Raymond Camden. This blog is running version 5.5.006. | Protected by Akismet | Blog with WordPress