Wednesday, March 17, 2010

Available assertions in cfcUnit

The documentation for cfcUnit is a little light. One of the first things I tried after going through the Getting Started with cfcUnit page on the cfcUnit site was doing an assertEquals. When I ran my test I got the error "Variable ASSERTEQUALS is undefined". So where's the list of available assertions? I couldn't find it so I went to the code. In org/cfcunit/framework/Assert.cfc I found the following available assertions:
  • assertArrayContainsNumber
  • assertArrayContainsString
  • assertComplexValue
  • assertComponent
  • assertContainsString
  • assertEqualsArray
  • assertEqualsBoolean
  • assertEqualsNumber
  • assertEqualsQuery
  • assertEqualsString
  • assertEqualsStruct
  • assertFalse
  • assertNotNull
  • assertNotNullComponent
  • assertNotRegexMatch
  • assertNotSameComponent
  • assertNotSameStruct
  • assertNull
  • assertNullComponent
  • assertObject
  • assertRegexMatch
  • assertSameComponent
  • assertSameStruct
  • assertSimpleValue
  • assertTrue
Not an assertion, but fail can also be used to fail a test case.

Update: After coming up with this list I found this site that contains the assertions, many with descriptions. Why I didn't find it earlier??

No comments:

Post a Comment