- Virtual file system. Treating an ftp site or an S3 instance as just another resource? BADASS.
- Railo's notion of contexts. Each app is an isolated thing. We've been working around that problem with CF for a long time. With railo, it's simply not a problem
- cfvideo is really, really cool. Now, I know that a lot of people don't want to see this in CF. And I know it won't be in the open source version of Railo. Still.... watching the kinds of sweet things Gert demoed, I can see its value
- var scope fixes
- injectMethod functionality for simple mocking
Last week's presentation at http://coldfusionmeetup.com was wrought with difficulties, but hopefully some of the concepts came across the frazzled wire ok and folks found a thing or two useful.
The code and presentation materials are available here: http://github.com/virtix/zoo/tree/master
Click the "download" button and you'll be given an option to download either a zip or tar. I've added Mike Rankin's code illustrating how to use SQL Server 2005 snapshots inside of MXUnit to keep your local database sandbox in a known state for testing. This is a great utility for those on SQL 05!
A really long time in the making, los hombres at MXUnit.org (http://mxunit.org) are finally distributing the first production release of their open source Unit Test Framework and Eclipse Plugin for ColdFusion Developers.
The big truth is that we want to get this version out because we are chomping at the bit to make MXUnit much more robust and flexible -"We're figuring on biggering and biggering ..." - Dr. Suess
Improvements since RC-1:
* More documentation and tutorials
* Dictionary and snippets for CFEclipse
* assertXPath(...) for testing generated html, xml, and anonymous web pages
* assertSame()/assertNoteSame() - Thanks Mark Mandel!
* HTML runner and remote web runner for test suites
* Test Blaster - recursive test stub generator
* Ant task: errorproperty/failure property, and more ...
* J2EE CFML open source (Railo/OBD) comparability issues addressed - Thanks Adam Haskel!
* And one, maybe two minor bug fixes ;-)
* Selenium Integration
* Annotations for flexibility
* Improved TestSuite constructs
* Test report generation (in lieu of JUnit reports)
* And more ...
* ColdFusion Meetup - "Database-centric Testing w/MXUnit", Thursday, July 17, 2008. 12:00 Noon EDT
* Adobe Max 2008 - "Advanced Patterns for ColdFusion Test Automation", Wednesday, November 19, 9:30 AM PST
* Easy to see your data with cfoutput, cfdump, and debug()
* Easy to run single test functions
* Easy "directory runner" for running entire directories of tests
* Easy to test private functions in your components
* Ability to switch to message-first style assertions to help ease transition from other frameworks
* A plethora of output formats from which to choose
* Ant Integration
* A team actively improving the framework, making testing easier, and providing abundant documentation
Special thanks out to Sean Corfield all the folks who really kicked the tires and gave good honest feedback! Keep 'em coming ...
The Guys at MXUnit.org
I need a way to test database logic and to persist those tests. In the past, I would open query analyzer type in some batch code, hit F5 and visually inspect the results. If all looked good, I would move it to a stored procedure, view, CF code, or some other object. There are a number of problems with this approach, and the one that bugs me the most is that the work product of this process becomes lost. Though I may have something working in the end, the pieces and what I was thinking at the time are gone, and at my age, that means gone forever.
Enter MXUnit ... using an xUnit framework to test a database? Why not? Ideally, it would be nice to have an xUnit database tool that allowed me to test snippets of batch code. I know there's sqlunit and dbunit that may work, but where I'm at, our db's are tied down pretty tight, but given a cf datasource and MXUnit, I can get pretty far. I can also wrap stored procedures up in tests and print out reports of database test suite runs for the dbas (more on this one later).
Here's a little gem that popped up the other day. Did you know you can define a CURSOR object inside of CFQUERY? I didn't, but here's is part of something I wanted to test:
---- Super Simple SQL Date Stuff ---- DECLARE @fiveMinutesAgo datetime, @rightnow datetime SELECT @rightnow = GETDATE() SELECT @fiveMinutesAgo = DATEADD (n, -5, @rightnow) PRINT @rightnow PRINT @fiveMinutesAgo ---- End ----
This simply prints the time the batch was run and that time less 5 minutes - mine eyes verify the correctness. Not too bad; certainly not automated; but, it has a smell that is becoming increasingly intolerable for me.
Here's the same thing written as an MXUnit test:
<cffunction name="testCallingDbDateFunctions"> <cfquery name="q" datasource="logparser"> DECLARE @fiveMinutesAgo datetime, @rightnow datetime SELECT @rightnow = GETDATE() SELECT @fiveMinutesAgo = DATEADD (n, -5, @rightnow) DECLARE dbTestCursor CURSOR FOR SELECT @rightnow as nowDate, @fiveMinutesAgo as fiveMinutesAgo; OPEN dbTestCursor; FETCH NEXT FROM dbTestCursor CLOSE dbTestCursor; DEALLOCATE dbTestCursor </cfquery> <cfscript> rightNow = q.nowDate; exepectedDate = dateAdd('n', -5, rightNow); fiveMinutesAgo = createODBCDateTime(q.fiveMinutesAgo); debug(q); assertEquals(exepectedDate,fiveMinutesAgo, "If broken, could be a date bug in CF or SQL."); </cfscript> </cffunction>
The debug output looks like this:
This looks like a lot of code to test such a simple piece of logic, and it is. But, the cool things about this for me, were (1) I can create a CURSOR object within CFQUERY and the name of the query becomes a reference to the CURSOR, and (2) I can use MXUnit and ColdFusion to run and persist database logic tests.
More on database testing soon ...