I am doing a big application that has a number of CFCs that connect to another application and also writing modifications to that application. You can imagine that things get a bit complicated after a while.
Once one gets to this level of complication, you need to start unit testing. So, I got myself CFCunit downloaded, and then I was a bit stumped, yes there is some documentation on how to do a simple TestCase, but my TestCases are NOT going to be simple (init should return an object, that object should have a value and not be empty in one of the properties, a certain method should return a struct, another an array etc etc). I couldnt find after following the documentation what were the assertions I could use, so I did a bit of digging through the code and using Spike’s CFC Documentation tool I managed to get all the assertions you can use.I hope this list helps other people. Next, I shall be setting up John Ashenfelter’s CFCUnit ant task (which I built myself from source, but dont know the syntax… anyone?)
assertArrayContainsNumber(array array, numeric value, [string failureMessage=""])
assertArrayContainsString(array array, string value, [string failureMessage=""])
assertComplexValue(any value, [string failureMessage=""])
assertComponent(any value, [string failureMessage=""])
assertContainsString(string string, string searchString, [string failureMessage=""])
Asserts that one string contains one or more instances of the specified searchString. If the seachString cannot be found, AssertionFailedError is thrown.assertEqualsArray(array expected, array actual, [string failureMessage=""])
Asserts that two Array are equal. If they are not an AssertionFailedError is thrown with the given message.assertEqualsBoolean(boolean expected, boolean actual, [string failureMessage=""])
Asserts that two booleans are equal. If they are not an AssertionFailedError is thrown with the given message.assertEqualsNumber(numeric expected, numeric actual, [string failureMessage=""])
Asserts that two numbers are equal. If they are not an AssertionFailedError is thrown with the given message.assertEqualsQuery(query expected, query actual, [string failureMessage=""])
Asserts that two Queries are equal. If they are not an AssertionFailedError is thrown with the given message.assertEqualsString(string expected, string actual, [string failureMessage=""])
Asserts that two strings are equal. If they are not an AssertionFailedError is thrown with the given message.assertEqualsStruct(struct expected, struct actual, [string failureMessage=""])
Asserts that two Structs are equal (value comparision). If they are not an AssertionFailedError is thrown with the given message.assertFalse(boolean condition, [string failureMessage=""])
Asserts that a condition is false. If it isn't it throws an AssertionFailedError with the given message.assertNotNull(any value, [string failureMessage=""])
assertNotNullComponent(component object, [string failureMessage=""])
assertNotRegexMatch(string regex, string string, [string failureMessage=""])
assertNotSameComponent(component expected, component actual, [string failureMessage=""])
Asserts that two components do not refer to the same object. If they do an AssertionFailedError is thrown with the given message.assertNotSameStruct(struct expected, struct actual, [string failureMessage=""])
Asserts that two structs do not refer to the same struct. If they do an AssertionFailedError is thrown with the given message.assertNull(any value, [string failureMessage=""])
assertNullComponent(component object, [string failureMessage=""])
assertObject(any value, [string failureMessage=""])
assertRegexMatch(string regex, string string, [string failureMessage=""])
assertSameComplex(any expected, any actual, [string failureMessage=""])
Asserts that two complex variables refer to the same object. If they are not an AssertionFailedError is thrown with the given message.assertSameComponent(component expected, component actual, [string failureMessage=""])
assertSameStruct(struct expected, struct actual, [string failureMessage=""])
Asserts that two structs refer to the same struct. If they are not an AssertionFailedError is thrown with the given message.assertSimpleValue(any value, [string failureMessage=""])
assertTrue(boolean condition, [string failureMessage=""])
Asserts that a condition is true. If it isn't it throws an AssertionFailedError with the given message.fail([string message=""])
Fails a test with the given message.
Tweet
comments powered by Disqus