ColdFusion Unit Testing With MXUnit and TextMate
Written by Simon Bailey
This post will show you how to get quickly up and running with ColdFusion, TextMate and MXUnit. As an example I will show you how to create a simple CFC with its corresponding unit test using MXUnit and then run the test locally within TextMate’s preview window.
1) Install TextMate:
2) Install the GetBundles tmbundle:
3) In TextMate:
Bundles > GetBundle > Install Bundle.
This will generate a list of available bundles, scroll down the list to ColdFusion and follow instructions to install.
4) Download and follow setup instructions for MXUnit (mxunit.org).
5) Create a new directory in your ColdFusion root and name it example_project.
6) You can now either open TextMate and drag the example_project onto the dock icon, or in Terminal cd to example_project and type:
7) Create an Application.cfc in the root of example_project by right clicking on the example_project directory in TextMate’s gutter and enter the following:
1 2 3 4 5
8) Create a new directory in example_project and name it com.
9) Within the newly created com directory create a new file named App.cfc and enter the following code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
10) Create the following package structure:
example_project > test
11) Within the test directory create AppTest.cfc and enter the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
12) In TextMate go to Bundles > Bundle Editor > Show Bundle Editor.
13) Select HTML from the list, click on the bottom left + icon in the Bundle Editor selecting New Command.
14) Enter the following command text amending the url to point to your ColdFusion localhost:
15) Ensure the AppTest.cfc class is open and hit your shortcut keys specified for the newly created command to see the below window