[dojo-contributors] unit test idioms: t.assertTrue and doh.assertTrue

Brian Douglas Skinner skinner at dojotoolkit.org
Mon Jun 11 19:41:07 EDT 2007

Another quick question about the doh unit test framework...

In looking through the existing unit tests, it seems like the norm is to 
write tests that look this:
     function testFoo(t){

The t arg is just a pointer to the global doh object, so ignoring t and 
calling doh.assertTrue works just as well:
     function testFoo(){

In writing my new unit tests, I've been using the doh.assertTrue() style 
rather than the t.assertTrue() style, because it seems more 
self-documenting.  For anyone who is new to the dojo unit test framework 
and reading through the unit tests, if you want to find documentation 
about assertTrue, then knowing that assertTrue is a function defined on 
the global doh object is useful info.  In contrast, knowing that 
assertTrue is a function defined on the t arg passed into the test 
function does not help you as much in figuring out where assertTrue is 

So here's my question: Is it okay if I go ahead and use 
doh.assertTrue(3>2) rather than t.assertTrue(3>2), or is there some 
compelling reason for using t instead?

:o) Brian

More information about the dojo-contributors mailing list