[Zope3-dev] Re: Javascript functional tests?

Marius Gedminas mgedmin at b4net.lt
Wed Mar 9 03:29:22 EST 2005


On Tue, Mar 08, 2005 at 09:43:03AM +0100, Roger Ineichen wrote:
> I prefere the JSUnitTest framework right now. The bad part on this
> is, it's implemented in Java and requires a Java Runtime.

JsUnit (http://www.edwardh.com/jsunit/) does not require anything but a
web browser.  Download, extract, point your web browser at it.  It can
be run on the server side as a some sort of a Java component, but that
bit is completely optional.

I do not like JsUnit's GUI, though -- you have to click with your mouse
and open popup windows to see your test failures.  I experimented a bit
with an alternative lightweight somewhat JsUnit-compatible test runner
that runs displays the results directly on an html page:
  http://mg.b4net.lt/planets/mg/test.html

> The nice part is, that it's totaly compatible in the syntax (XUnitTest).
> You ca use almost the same methods for testing like we allready use.
> 
> E.g.
> assertEqual, assertNotEquals, assert(isValidZipCode("90210")); 

However it has the comment and assertion swapped, which bugs me:

  assertEqual("foo must be 42", 42, foo);

Also, the expected value comes first in assertEqual in JsUnit, otherwise
the failure will be misleading, and I've become used to writing

  self.assertEquals(result, expected, msg)

in PyUnit.

But these are minor matters, JsUnit is much better than no unit tests at
all for your Javascript.

BTW ecmaunit sounds interesting, I should check it out.

Marius Gedminas
-- 
"question = (to) ? be : !be;" -- Shakespeare
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mail.zope.org/pipermail/zope3-dev/attachments/20050309/184be9c1/attachment-0001.bin


More information about the Zope3-dev mailing list