Case-sensitive assertEquals Assertion in MXUnit

If you use the MXUnit testing framework for ColdFusion, you might have come across this earlier — the assertEquals assertion is case-insensitive.

This means that if you try and compare a string like ‘abs’ and ‘Abs’, assertEquals returns true.

And that is ok in certain cases, but is not ok in many other. I guess it boils down to the fact that at the end of the day, ColdFusion is case-insensitive. A variable called ‘firstName’ is the treated the same as ‘FirstName’.

But enough of that.

So how do you test for case-sensitivity in assertEquals assertion?

First I thought I’d write my own assertion. But then there is a much simpler solution. Simply hash the the two strings that one needs to compare and assert that they are NOT equal.

So rather than:

assertEquals("abs", "Abs")

Use

assertNotEquals(hash("abs"), hash("Abs"))

It works quite nicely.

Do you do it differently?

BTW, there some discussion of this on the MXUnit Google Groups as well.

Testing for Success — My presentation at Web on the Piste 2008

A couple of weeks ago, I spoke at the RIA conference Web on the Piste 2008 on the topic of “Testing for Success”.

Over the past few years, I’ve worked with many ColdFusion and Flex development teams. It has been interesting to see that there is more interest in test-driven development. However, a lot of times team leaders/company executives overlook the bigger picture and focus on just the details. And the lack of this larger context can lead to less effective/failed testing practices. My presentation this year was focused on presenting this bigger picture with focus on ColdFusion and Flex.

You can download the presentation here or view it at Slideshare.

By the way, for those of you who have not heard about Web on the Piste, it is a conference on Rich Internet Technologies that takes place every year in the beautiful Queenstown in New Zealand.