>>> testIsNullID(crTracker2._com.test.propertyTest): : expected:<...> but
>was:<...>
>
>Yes, this is copied verbatim and that is what really threw me. What in the
>world does that mean?
>
>Robert - I will try out some of your suggestions, but as Sean said, what is
>the '...' as a value?
>
>-- Jeff
The CFUnit outputs will try to trim down longer strings so that if you only see
the part that is different. For example, if you had these two strings:
expected = "Hello World, My name is Rob";
actual = "Hello World, My name is John";
Then the failure message might be something like
testSomthing(com.myTest): : expected:<... is Rob> but was:<... is John>
This is done to make massages about of very long strings, like XML, readable.
So when you see:
testSomthing(com.myTest): : expected:<...> but was:<...>
That means that the comparison logic said that the two variables where
different, but that when the logic tried to trim the strings down it could not
find the part that was different.
You are probably correct, it is probable the formatting of the two boolean
values are slightly different (1/0 vs yes/no vs true/false), so that the
comparison failed, but the formatting couldnât see the difference. Iâll
have to investigate this and correct it.
Note: The reason I left CFUnit dynamically typed was because ColdFusion is
dynamically typed. So therefore, in my opinion, so should its unit tests. So in
CFUnit all simple values are the same in assertEquals. A bit, integer, floating
number, and string are all the "simple" data type in CFML, so they are
evaluated the same way in the unit tests. Therefore, if you have a method that
returns type "numeric" you can still do this...
assertEquals("some message", myMethod(), "123");
Even though the 123 is in quotes - and therefore would be considered a string
in most strongly typed languages - ColdFusion still sees them both as simple
values, and can still consider them to be equal.
This does mean that when evaluating numbers (floating or integers) in CFUnit
you may need to wrap them in the numberFormat() function to insure they are
formatted the same. (However, when evaluating boolean values, I would suggest
using assertTrue/false).
In CFUnit, if you wanted to assert that a variable was a specific type, then
you would do one of these:
assertTrue("my message", IsBoolean( myvariable ) );
assertTrue("my message", IsNumeric( myvariable ) );
assertTrue("my message", IsDate( myvariable ) );
assertTrue("my message", IsObject( myvariable ) );
assertTrue("my message", IsXML( myvariable ) );
assertTrue("my message", IsArray( myvariable ) );
assertTrue("my message", IsStruct( myvariable ) );
assertTrue("my message", IsQuery( myvariable ) );
assertTrue("my message", IsBinary( myvariable ) );
ect... ect...
For example:
var expected = "123";
var myvariable = myCFC.getNumber();
assertTrue("The returned value is not a valid number", Is IsNumeric (
myvariable ) );
assertEquals("The returned value is not the expected value",
numberFormat(expected),
numberFormat(myvariable)
);
In this example, I would get a different (more informative) message if my
returned value was not numeric then I would if it was not the expected value.
(note: the assertEquals would still fail even if I did not assert the variables
type prior to calling it, because numberFormat would throw an error, but that
would be CFML thrown error, not a failure which I handle. Which you may or many
not prefer)
As mentioned before, CFCUnit has typed assertions. I personally prefer a single
assertion method myself, and feel this actually gives me more freedom. I guess
it comes down to personal preference.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:225421
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54