Guys,

While I agree with using javascript syntax for involved tests, I have tried to use jsUnit for unit tests of involved javascript browser code. I have found some issues and little support.

1) using Firefox (mozilla) I found that the strong cache of firefox caused tests to fail on the second exectution of a suite. The only solution was to restart FF after clearing out the cache. very little discourages an engineer from running tests like this kind of obstacle. Firefox on the Mac was even worse. And yes we tried to change FF's config so it would requery the page each time, and set the page header's cache control settings and the HTTP cache settings, ff still foudn a cached version to be better that the one it needed to load from the server for the tests to pass. Attached

2) jsUnit has issues with cross browser scripting. Mostly you can overcome these, but try controlling the mouse in a browser and you will not be having fun. At least if you are let me know what you are doing PLEASE.

The main point of my post is that jsUnit is not well supported so if it needs changes you might be on your own. And since it is crafted to reload pages in situ you may find issues with mulitple tests.

I would suggest trying just jsunit standalone first and then port to selenium if it is solid. Just my two cents.

Thanks,
Nate

PS attached is a port I made to the jsunit mailing list. No-one ever responded.

----- Original Message ----- From: "Jason R Huggins" <[EMAIL PROTECTED]>
To: <selenium-users@lists.public.thoughtworks.org>
Sent: Thursday, December 01, 2005 12:56 AM
Subject: Re: [Selenium-users] Using JsUnit together with Selenium?


Dan Fabulich wrote on 11/30/2005 05:27:28 PM:
One of the side projects I've been working on this week is to try using
JsUnit as a runner for Selenium tests, instead of HTML-table Selenese.
This would make it easier to write complicated tests with conditionals,
loops, etc..

Nice... JavaScript syntax for Selenium tests has been on my wish list for
a while.

(I can't be the first person to have thought of this...?  Didn't
Selenium
at one time depend on JsUnit?)

Selenium tests itself with table-style functional tests and comes with
JsUnit unit tests for the core Selenium code. Selenium used to depend on
JsUnit for its library of assert commands, but later on we decided to nix
that dependency and use our own API.

Before Selenium was created, I gave a look at JsUnit before deciding to
write my own tool.  A few things kept me from just sticking with JsUnit.
The biggest reason is that JsUnit looked like it could easily handle the
testing of single, discreet web pages... But it couldn't handle (and is
not meant to handle) the transitions between pages (e.g.: enter data in a
form, click a button, wait for new page, then proceed with the next
command)-- aka "login to logout" style tests. Also, the JsUnit docs say
that you could make the hidden iframe visible (like Selenium does)-- but
only in IE. And I like the "stepping debugger" aspect of Selenium's
interface for slowly stepping through tests to find out where and how a
test failed. I didn't see how to easily do that with JsUnit. Lastly, at
the time, I was enamored with Ward's FIT Framework, and its promise of
"tests that people can read". Once I realized that JsUnit wasn't really
meant for my idea of functional testing, Selenium started out as an
experiment to implement FIT in JavaScript in the browser. FIT/tables-style
Selenium is not going away, but I've since come around to supporting the
idea of using plain old JavaScript syntax for tests when you need to do
more complicated stuff than simple procedural commands (conditionals,
loops, function definitions, etc.) In this case, I'd like to move to API
similar to Watir's, but written in JavaScript. Anyway... there are lots of
good ideas to borrow from in each project.


Anyway, it turns out to be pretty easy to use Selenium in a JsUnit
context.  JsUnit's TestRunner.html defines a handy invisible iframe
that's
pretty analogous to SeleniumRunner.html's "imyframe".  You access it
like
this:

(snip, snip)
The main tricky part turns out to be waiting for events.
(snip, snip)
Many people have remarked about this as a weakness in JsUnit for testing

asynchronous events.

This is an area that we do have working in Selenium. Although there is a
proposal from Bret Pettichord to change or improve how we do it in
Selenium.
Getting the browser to wait is damn tricky business. Read these two posts
from some "color commentary" on the subject.
http://www.josephmoore.net/2005/11/non-cpu-intensive-javascript-wait-loop.html
http://www.josephmoore.net/2005/11/using-seleniums-waitforvalue.html

I've found a reasonable kludge for this, which I've
posted to the JsUnit mailing list (free subscription required):
http://groups.yahoo.com/group/jsunit/message/460

Yes, requiring a Java applet or ActiveX control to implement a wait
command is very kludgey. :-)

Putting the two together, you can use Selenium and the BrowserBot very
effectively in pure JsUnit tests to write your tests in pure JavaScript.

Because of the timing/event issues... I'm thinking it might be easier to
run pure JavaScript tests in Selenium's TestRunner test harness than
running Selenium tests in JsUnit's TestRunner. I think the way forward
with this is to replace Selenium's parsing of a Selenium table with a
simple "eval" of a pure JavaScript test and see what happens.

Is this helpful to anyone?  Am I the only one who prefers writing tests
in
JavaScript rather than HTML-table Selenese?

Yes, this is helpful (to me at least)... And I know for sure you're not
the only one who'd like to write their Selenium tests in pure JavaScript.

-Jason
_______________________________________________
Selenium-users mailing list
Selenium-users@lists.public.thoughtworks.org
http://lists.public.thoughtworks.org/mailman/listinfo/selenium-users


--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.362 / Virus Database: 267.13.10/189 - Release Date: 11/30/2005


--- Begin Message ---
Hi All,
 
I am having a problem with jsUnit under mozilla.  The app in question uses Ajax specifically DWR.
 
The problem is on the second execution of the tests.  An alert with "name not defined" is executed on line 111 of xbDebug.js.  This makes running the tests very laborious.  I added a check for an '[' at the start of the name and then it avoids emission of the alert.  This is a bandaid and a hack.
 
The real problem appears to be that mozilla is very aggressive about caching (in what I guess to be a concern for performance).  It therefpre attempt to avoid loading anything it can.  In this effort \dwr\engine.js does not get rerun, therefore the DWREngine variable does not get initialized.  This appear to not allow the tests to succeed, however the debug window appears with many messages.
 
This all appears in part because of the way jsUnit loads the page using location.ref=filename in the testContainer.  I am not sure on this.
 
If anyone has any idea about how to get mozilla to relax it's caching I would appreciate it. I tried the meta tags CACHE-CONTROL=no-cache and PRAGMA=no-cache to no avail. 
 
Thanks in advance,
Nate
 


SPONSORED LINKS
Software distribution Salon software Medical software
Software association Software deployment Service software


YAHOO! GROUPS LINKS




No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.361 / Virus Database: 267.12.4/146 - Release Date: 10/21/2005

--- End Message ---
_______________________________________________
Selenium-users mailing list
Selenium-users@lists.public.thoughtworks.org
http://lists.public.thoughtworks.org/mailman/listinfo/selenium-users

Reply via email to