First Test Case

Getting Started with MXUnit

We built MXUnit to make it as easy as possible to write tests. The framework is designed to facilitate, not get in the way. So, let's write some code.

Setup: http://mxunit.org/download.cfm

  • Download and install MXUnit directly under your webroot; e.g.; http://localhost:8500/mxunit/
  • Create a directory in /mxunit/doc/tutorial and call it mytests

Following Kent Beck's Test Driven Development (TDD) we will follow this simple method:

  1. Write the test first
  2. Watch the test fail
  3. Write the component
  4. Watch the test pass

1.Write the test first.

Type the following code into a new file called MyComponentTest.cfc and save it to /mxunit/doc/tutorial/mytests

MyComponentTest.cfc

2. Watch the test fail.

http://localhost:8500/mxunit/doc/tutorial/mytests/MyComponentTest.cfc?method=runTestRemote
Change the server name and port as needed.
You should see this:

Believe it or not, this is good! This error is exactly what we expect. This tells us that our component, MyComponent, does not exist.

3. Write the component.

Type the following code into a new file called MyComponent.cfc and save it to /mxunit/doc/tutorial/mytests

MyComponent.cfc

4. Watch the test pass.

http://localhost:8500/mxunit/doc/tutorial/mytests/MyComponentTest.cfc?method=runTestRemote
You should see this:

Next - More Test Cases

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Aug 26, 2010

    David Mineer says:

    In the default download I received the only folder under mxunit/doc is 'api'. T...

    In the default download I received the only folder under mxunit/doc is 'api'. This throws the instructions off a bit unless you add a tutorial directory under 'doc', then you can continue as instructed.