18

As a related sub-question - are there any CF unit test frameworks that support or make it easier to use mocks/stubs?

The 2 that I spotted in a quick google that look the most promising are MXUnit and CFUnit. Are there others, and which one(s) have the widest adoption and active development? Enough questions crammed into one?

Basically I want to make a good choice.

edit Note that at the time of writing the question originally, MXUnit was the go-to and TestBox wouldn't be on github for a few years yet. See comments on the accepted answer.

jinglesthula
  • 4,446
  • 4
  • 45
  • 79

3 Answers3

15

Pretty sure that the only CF unit test framework still in active development is MXUnit.

Check out MockBox (also in active development) for support in using mocks/stubs.
http://wiki.coldbox.org/wiki/MockBox.cfm

Edit: Be sure to follow the MXUnit google group. http://groups.google.com/group/mxunit/topics

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
charliegriefer
  • 3,342
  • 1
  • 18
  • 20
  • 4
    MXUnit supports mocking as well through MightMock - http://wiki.mxunit.org/display/default/Mocking+and+Stubbing. If you'd rather swap that out for Mockbox though then they give you the ability to do that also - http://wiki.mxunit.org/display/default/Using+External+Mocking+Frameworks – James Buckingham Sep 30 '11 at 08:09
  • And there is RocketUnit http://rocketboots.com.au/blog/index.cfm?mode=entry&entry=E565633C-E081-51EF-A7F883614F752942 – Mike Henke Sep 30 '11 at 12:51
  • Awesome - good information. That's the beauty of SO - someone in my particular situation looking for a similar answer will hopefully also benefit from knowing about things like MightMock, Mockbox, RocketUnit, and Selenium (see mz_01's answer) where just googling might only quickly turn up MXUnit and CFUnit. Thanks all :) – jinglesthula Sep 30 '11 at 22:11
  • Changing the accepted answer to reflect the current state of things. It does look like MXUnit hasn't had more than a small handful of commits in recent years, where TestBox is being actively developed. Hopefully that helps anyone starting out with testing in CF. – jinglesthula Aug 14 '17 at 18:27
8

TestBox is a new xUnit and BDD style framework that is compatible with MXUnit and comes with MockBox which is a full mocking and stubbing library. Both of these are actively developed and professionally supported by Ortus Solutions.

https://testbox.ortusbooks.com/introduction/installing-testbox

https://testbox.ortusbooks.com/mocking/mockbox/installing-mockbox

Brad Wood
  • 3,863
  • 16
  • 23
  • Hey Brad! Thanks for adding this one. This is one I recently learned of and I'm excited to learn more about it. Once I get a chance to dig in and update comments here (and on the accepted answer) with my experience. I may even change this to the accepted answer :) – jinglesthula Feb 07 '14 at 00:01
  • No Problem. MXUnit has basically stopped all new development for quite some time now. Please join the main ColdBox Google Group if you have questions or need help: https://groups.google.com/forum/?hl=en#!forum/coldbox Here is a video introduction to TestBox: http://blog.coldbox.org/blog/coldbox-connection-video-intro-to-testbox And here are live TestBox samples you can run in your browser: http://runnable.com/UsyCKoc0i3w-AADF/testbox-samples-for-coldfusion-cfml-railo-mxunit-bdd-tdd-and-xunit – Brad Wood Feb 07 '14 at 03:33
  • Isn't TestBox compatible only with CF 10 though? – Geo Mar 21 '14 at 21:21
  • That is not correct. You can do XUnit and MXUnit compat test with TestBox on CF9. It is the BDD-style tests specifically that require closures and therefore can only be done on Railo and CF10. It's all explained here in our docs: http://wiki.coldbox.org/wiki/TestBox.cfm#System_Requirements – Brad Wood Mar 22 '14 at 01:08
  • @BradWood Links are dead. – benbotto May 29 '18 at 15:35
  • Thanks for letting me know. I updated the answer to have the correct links. I can't edit my comment above, so here is the new link for that: https://testbox.ortusbooks.com/introduction/overview/system-requirements – Brad Wood May 29 '18 at 19:33
4

Don't forget http://github.com/bobsilverberg/CFSelenium

mz_01
  • 495
  • 3
  • 13
  • I've very little experience with testing in Selenium or CFSelenium but I'm curious - where does mocking play a role in those? – James Buckingham Sep 30 '11 at 08:17
  • 1
    Isn't Selenium for user interface testing rather than unit testing? – Carl Von Stetten Sep 30 '11 at 14:40
  • 1
    Projects like Selenium or QUnit can also be used to test any Javascript-based business logic (e.g. client-side stage of your input validation). And don't forget that it's possible to combine server-side testing (e.g. MXUnit) and client-side testing (e.g. Selenium). Think of stuff like testing AJAX requests against CF webservices. – mz_01 Oct 05 '11 at 12:19