Testing MXUnit

When making changes to the MXUnit framework it's a good idea to test those changes to ensure you haven't broken anything. Luckily MXUnit can be used to test itself! Methods of running MXUnit's tests include:

  1. via the Eclipse plugin
  2. via the browser
  3. via the ant task


There are unit tests which are designed to test the integration between MXUnit and a number of mocking frameworks. If you do not have those mocking frameworks installed you will see errors and test failures in mxunit.tests.framework.TestCaseTest. The frameworks required, and their expected locations are:

  • MightyMock - this now ships with MXUnit so it will always be available
  • ColdMock - this is expected to be found in /coldmock
  • MockBox - this is expected to be found in /Coldbox/system/testing

Running the Unit Tests via the Eclipse Plugin

In the Navigator tab, simply point to the /tests folder, off of the MXUnit root, right-click, and choose Run MXUnit Tests. You should see the results of the tests in the MXUnit tab.

Expected Errors and Failures

Fixtures Can Be Safely Ignored

When running all of the tests in the /tests folder, some errors and failures will be reported. Most of these are due to fixtures being run as tests, so you can safely ignore any errors or failures reported from test cases that reside in a folder with the word fixture in its name.

Expected Failures

  • testAdd2() in mxunit.tests.samples.MyComponentTest fails with an mxunit.exception.AssertionFailedError failure. It can be safely ignored.
  • mismatchedArgumentTypesShouldFail() in mxunit.tests.mightymock.ArgumentMatcherTest fails because it is a placeholder for unimplemented logic.
  • attemptingToRegisterTheSamePatternShouldThrowMeaningfulException() in mxunit.tests.mightymock.InvocationTestArgumentMatcherTest fails as a reminder to fix or document an issue.
  • testWriteLog() in mxunit.tests.mightymock.MockLoggerTest fails because it is a placeholder for unimplemented logic.
  • $addInvocationRecordForBothPatternAndLiteral() in mxunit.tests.mightymock.MockRegistryTest fails because it is a placeholder for unimplemented logic.
  • howToHandlePatternVerification() in mxunit.tests.mightymock.MockVerificationTest fails because it is a placeholder for unimplemented logic.
  • $verifyExact() in mxunit.tests.mightymock.OrderTest fails because it is a placeholder for unimplemented logic.
  • shouldBeAbleToVerifyBothePatternAndLiteral() in mxunit.tests.mightymock.PatternInvocationTest fails because it is a placeholder for unimplemented logic.

Running the Unit Tests via the Browser

  You can run mxunit/tests/run.cfm in your browser. For example, I run it at http://localhost/mxunit/tests/run.cfm

Running the Unit Tests via ANT

Setting your "paths"

  • In mxunit/buildprops, copy the contents of the antrunner_sample.properties file. Create a new file in that directory named "antrunner.properties"
  • Fill in your server, port, and webroot properties and save the file. For example, mine looks like this:

Running the tests

  • From within Eclipse, drag mxunit/build.xml into the Ant view
    *Run the "runTests" target
    *It'll print out the results in the console view. A run should look something like this:
ANT output from runTests

Viewing the JUnit Report

The runTests target will create JUnit XML and run it through the JUnitReport task. This creates an HTML view of the test results. They are placed in mxunit/tests/testresults/html

You can view them in the browser by going to http://<yourserver>:port/mxunit/tests/testresults/html/index.html. It'll look something like this:

When you run the tests via run.cfm or via ANT, the "fixtures" and "samples" tests are all filtered out, so you needn't mentally filter them yourself
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.