Unit testing our exception handling

Anastasia Cheetham a.cheetham at utoronto.ca
Mon Aug 11 16:04:45 UTC 2008


A recent change to the Fluid framework's infrastructure has made it  
difficult to unit test our exception handling.

The unit tests in FluidJSTest.js attempt to confirm that if you try to  
initialize a components with an invalid container element, an  
exception occurs. When you run the unit tests, the exception does,  
indeed occur.

The problem is this: Our fluid.fail() function, which is correctly  
being called, now deliberately causes an error to occur. This is good,  
because otherwise in the real world, there would be no indication that  
anything was wrong. But in the unit tests, this has the effect of  
halting the execution of the script, which means that any further  
tests are skipped altogether - with no indication that they even  
should have been run. If you open the unit test file in the browser,  
you see all green. If you don't look at the status bar along the  
bottom of the window, you wouldn't even know anything was amiss.

I'm not sure what's a good approach to dealing with this issue. Move  
the test for the exception to be the very last test in the script?  
That's a bit brittle...

Any other suggestions?

-- 
Anastasia Cheetham                   a.cheetham at utoronto.ca
Software Designer, Fluid Project    http://fluidproject.org
Adaptive Technology Resource Centre / University of Toronto




More information about the fluid-work mailing list