A while back I wrote an entry describing how to use the Java Equal() method to compare two structs. I had looked this up because I was writing some unit tests and (obviously) needed to assert that one struct was equal to another struct.
As usual I probably should have referenced the CFC Unit docs before referencing the Java docs. Nonetheless, I did recently take a look at the assert methods provided in CFC Unit. In case your interested they can be viewed here. So there is an assert method assertEqualsStruct() that from what I can tell compares the data and structure of two structs. As such if you’re writing unit tests using CFCUnit you can also use this assert to perform the same check. Again from what I can tell they both do the same thing. So just wanted to post the update.
Matt, you should really consider moving to MXUnit. Marc and Bill do a ton of great work and it has all the assertions you would ever need as well as built-in ways of catching exceptions, mocking objects, etc. I’m not a great unit tester but MXUnit is the best of breed out there for CF developers these days.
For the most part it’s a drop in replacement for CFCunit code but then it opens up a lot of new capabilities.
Thanks for the suggestion Brian! I’ve never used mxunit, but will definitely bring it up as a suggestion to the powers that be. I will be helping to migrate our application to CF9 some time this year, so maybe that will be a good opportunity to look into updating our unit testing framework as well. Have you migrated from CFCUnit to MXUnit? I’m just curious if the assertions would need to be updated and if we could just extend a new framework in each of our test cfcs. We currently have a ton of unit tests and would want a solution that’s an easy migration.
You’ve got it – basically change what CFC it extends and they should just work. I believe MXUnit has a full set of assertions to match CFCUnit. As you can see on cfcunit.org, the last update was 2006. Check out mxunit.org.