ColdFusion Unit Testing With MXUnit and IntelliJ IDEA
This post will show you how to get quickly up and running Unit Testing with ColdFusion and IntelliJ IDEA. 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 in your browser. This mirrors the project example in the similar post I made earlier on in the week: ColdFusion Unit Testing with MXUnit and TextMate.
1) Install IntelliJ IDEA:
2) Download and follow setup instructions for MXUnit (mxunit.org).
3) Create a new project in IntelliJ: File > New Project.
4) Keep the default Create project from scratch option and click next.
5) Name your project example_project and ensure your project files location is in your ColdFusion root e.g. /Users/newtriks/Sites/example_project
6) Ensure create module is selected and the module to use is the default Java Module and click next.
7) Select do not create a src directory and then click next and then finish.
8) Create an Application.cfc in the root of example_project by right clicking on the example_project directory > New > ColdFusion Tag Component and enter the following:
1 2 3 4 5 | |
9) Create a new directory in example_project and name it com.
10) 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 | |
11) Create the following package structure:
example_project > test
12) 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 | |
13) Select: Run > Edit Configurations and add a new configuration by clicking the plus icon in the top left corner.
14) Select ColdFusion in the list of available run configurations and name it test-example.
15) In the web path input field enter the below url (amend your localhost param accordingly) and click OK:
1
| |
16) Select Run > Run or click the green triangle in the toolbar. You should see the below image:
