ColdFusion unit test frameworks
Asked Answered
D

3

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.

Datura answered 30/9, 2011 at 3:54 Comment(1)
See carehart.org/cf411/#cfmlunittestPhotochronograph
R
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

Roughen answered 6/2, 2014 at 18:28 Comment(6)
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 :)Datura
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: groups.google.com/forum/?hl=en#!forum/coldbox Here is a video introduction to TestBox: blog.coldbox.org/blog/coldbox-connection-video-intro-to-testbox And here are live TestBox samples you can run in your browser: runnable.com/UsyCKoc0i3w-AADF/…Roughen
Isn't TestBox compatible only with CF 10 though?Freon
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: wiki.coldbox.org/wiki/TestBox.cfm#System_RequirementsRoughen
@BradWood Links are dead.Liuka
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: testbox.ortusbooks.com/introduction/overview/…Roughen
W
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

Wilburnwilburt answered 30/9, 2011 at 4:7 Comment(4)
MXUnit supports mocking as well through MightMock - 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 - wiki.mxunit.org/display/default/…Richards
And there is RocketUnit rocketboots.com.au/blog/…Pintail
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 :)Datura
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.Datura
R
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

Roughen answered 6/2, 2014 at 18:28 Comment(6)
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 :)Datura
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: groups.google.com/forum/?hl=en#!forum/coldbox Here is a video introduction to TestBox: blog.coldbox.org/blog/coldbox-connection-video-intro-to-testbox And here are live TestBox samples you can run in your browser: runnable.com/UsyCKoc0i3w-AADF/…Roughen
Isn't TestBox compatible only with CF 10 though?Freon
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: wiki.coldbox.org/wiki/TestBox.cfm#System_RequirementsRoughen
@BradWood Links are dead.Liuka
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: testbox.ortusbooks.com/introduction/overview/…Roughen
K
4

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

Kensell answered 30/9, 2011 at 5:34 Comment(3)
I've very little experience with testing in Selenium or CFSelenium but I'm curious - where does mocking play a role in those?Richards
Isn't Selenium for user interface testing rather than unit testing?Valdez
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.Kensell

© 2022 - 2024 — McMap. All rights reserved.