Is this something that we should/could add to our unit test framework?
- Justin
On 9-Feb-09, at 11:21 AM, Colin Clark wrote:
Michelle,
This is a really nifty strategy. Thanks for sharing it with the
list. One quick comment below...
On 6-Feb-09, at 2:59 PM, Michelle D'Souza wrote:
I've spent a couple hours today trying to get the table of contents
tests passing and now that they are working I thought I'd share
what I learned (thanks Antranig). The problem I ran into was that
the code I was testing had an AJAX call in it. I needed to run the
test after the AJAX call returned. Our general test writing pattern
will not work in this case, instead I used our event system to run
the test. This is not a perfect solution since the test knows an
implementation detail of the code (that there is an AJAX call) but
I couldn't think of a better way to write this.
Actually, I don't think this does reveal an implementation detail to
the test code, or to anyone else for that matter. You've
encapsulated this into a standard Infusion event ("myEvent"), so the
contract is clear. The specifics of the AJAX call, however, don't
leak out into user code. This is a good thing.
Plus, generally users of this code would generally want to know
about the fact that an AJAX call is being made so that they can use
the event wisely.
Colin
If you are going to use this strategy for code you are testing, it
is important to remember that the test itself needs to start inside
the event handler. This pattern looks like this:
(function ($) {
$(document).ready(function () {
var tests = new jqUnit.TestCase("My Tests");
var myEventHandler = function () {
tests.test("My Test", function () {
assertTrue("this is a test", true);
});
};
var options = {
listeners: {
myEvent: myEventHandler
}
};
fluid.myComponent(container, options);
});
})(jQuery);
------------------------------------------------------
Michelle D'Souza
Software Developer, Fluid Project
Adaptive Technology Resource Centre
University of Toronto
_______________________________________________________
fluid-work mailing list - [email protected]
To unsubscribe, change settings or access archives,
see http://fluidproject.org/mailman/listinfo/fluid-work
---
Colin Clark
Technical Lead, Fluid Project
Adaptive Technology Resource Centre, University of Toronto
http://fluidproject.org
_______________________________________________________
fluid-work mailing list - [email protected]
To unsubscribe, change settings or access archives,
see http://fluidproject.org/mailman/listinfo/fluid-work
_______________________________________________________
fluid-work mailing list - [email protected]
To unsubscribe, change settings or access archives,
see http://fluidproject.org/mailman/listinfo/fluid-work