I haven't heard of anyone testing SVG with JsUnit yet, and in fact I
wasn't familiar with the SVG technology at all. But I read a little
about it and it's very exciting. For those who don't know about it,
here are some links:
http://www.w3.org/Graphics/SVG/Overview.htm8http://www.adobe.com/svg/main.htmlhttp://www.sun.com/software/xml/developers/svg/http://xml.apache.org/batik/
I'd be very keen to work on a JsUnit adaptation or extension to test
the Adobe plugin and the Java stuff from Apache. As I say, I'm
unfamiliar with it; perhaps you could post your current thoughts on
the kinds of tests you would be able to write?
- Edward
--- In jsunit@y..., carnold@h... wrote:
> Anybody thought about running JSUnit under SVG (as an alternative
to
> HTML or WSH)?
>
> One of my interests in JSUnit is testing DOM implementation of the
> Adobe SVG viewer. Couldn't do a combo box without writing a lot of
> event handling code, but could put a list of detected scripts with
> hyperlinks.
>
> The Adobe SVG viewer can be tested being driven from IE, however
the
> appeal of a pure SVG + JS implementation would be that it could
also
> be used to test the Apache Batik (SVG in Java) project.
So the problem really is that you've got multiple frames and
JavaScript in some frames calls JavaScript in other frames, and
JavaScript is all defined in the pages, not in external files, so
that you can't include the files into your test page.
It doesn't really make any difference that these pages are ASPs: the
problem exists even if they are just straight HTML files.
To get around this and test each page, here's what I would suggest:
put your Test Functions in the frameset page, and have that be your
Test Page. The Test Functions in that page can access the frames as
usual. If you don't want to permanently add Test Functions to the
frameset page, perhaps you could call the frameset ASP with "?
isForTesting=true", in which case the ASP would add the Test
Functions, and otherwise not. For example, your frameset Test Page,
myPage.asp, might look like this:
<html>
<frameset rows="60,100,*">
<frame src="page1.asp" name="page1">
<frame src="page2.asp" name="page2">
<frame src="page3.asp" name="page3">
</frameset>
<script language="javascript"
src="/jsunit/app/jsunitcore.js"></script>
<script language="javascript">
function testXXX() {
assertEquals("foo", page1.getString());
...
}
function testYYY() {
assert(page3.isInInitialState());
...
}
</script>
</html>
- Edward
--- In jsunit@y..., bnadesan@l... wrote:
> Hi Edward,
>
> I have a test pages now, I need to use this test pages to test the
> javascript functions which resides in an asp page say (index.asp).
> Now the javascript functions in index.asp calls javascripts
functions
> of say, data.asp and main.asp. In short the javascript functions in
> index.asp calls the functions in other asp pages also.
>
> The Asp pages contains client side javascript functions which are
> defined within the asp itself and not in a seperate .js file. How
can
> I test these functions using a test page
>
> Note all the three pages are loaded through frames.
>
> My question is How can I test the functions in all the three asp
> pages using a test page? Do you think this can
> be achieved using Jsunit. I was trying hard to find a solution to
> this.
>
> Thanks a Lot...
Hi Edward,
I have a test pages now, I need to use this test pages to test the
javascript functions which resides in an asp page say (index.asp).
Now the javascript functions in index.asp calls javascripts functions
of say, data.asp and main.asp. In short the javascript functions in
index.asp calls the functions in other asp pages also.
The Asp pages contains client side javascript functions which are
defined within the asp itself and not in a seperate .js file. How can
I test these functions using a test page
Note all the three pages are loaded through frames.
My question is How can I test the functions in all the three asp
pages using a test page? Do you think this can
be achieved using Jsunit. I was trying hard to find a solution to
this.
Thanks a Lot...
Hello Edward,
The Asp pages contains client side javascript functions which are
defined within the asp itself and not in a seperate .js file. How can
I use the these functions using a test page
--- In jsunit@y..., edward@j... wrote:
> So I think what you are trying to do is to write a Test Page which
> includes an ASP file on an IIS webserver in which your JavaScript
is
> defined. This ASP must produce a JavaScript file. That's fine -
it
> should work (although I've never seen an ASP which doesn't result
in
> an HTML page!).
>
> Is that what you're trying to do? I think it is, except you say
that
> the page below IS test.asp, which confuses me. I think you mean
that
> the page below is just myTestPage.html or whatever and that it
> includes test.asp. If so then my guess would be that something is
> wrong with test.asp - could you post the source?
>
> - Edward
>
> --- In jsunit@y..., bnadesan@l... wrote:
> > Can I test Javascript in an ASP page using JSUnit. I tried out
> > something like this using JsUnit. It didn't work
> > can please have a quick look at it. The Javascript is function
> > multiplyAndAddFive() is in the test.asp.
> >
> > The function name:multiplyAndAddFive(-4, 5) is in Test.asp. The
> > test.asp page is listed below......
> >
> > <!..test.asp-->
> > <!--http://bn20785/AgentGUI/test.asp: where bn20785 is the
> webserver--
> > >
> > <html>
> > <head>
> > <title>Test Page for multiplyAndAddFive(value1, value2)</title>
> > <!-- note the asp in the src attribute--------------------->
> > <script language="javascript"
> > src="http://bn20785/AgentGUI/test.asp"></script>
> >
> > <script language="javascript"
src="./app/jsUnitCore.js"></script>
> > </head>
> > <body>
> > <script language="javascript">
> > function testWithValidArgs() {
> > assertEquals("2 times 3 plus 5 is 11", 11, multiplyAndAddFive
> (2,
> > 3));
> > assertEquals("Should work with negative numbers", -15,
> > multiplyAndAddFive(-4, 5));
> > }
> > function testWithInvalidArgs() {
> > assertNull("A null argument should result in null",
> > multiplyAndAddFive(2, null));
> > assertNull("A string argument should result in null",
> > multiplyAndAddFive(2, "a string"));
> > }
> > function testStrictReturnType() {
> > assertNotEquals("Should return a number, not a string", "11",
> > multiplyAndAddFive(2, 3));
> > }
> > function testWithUndefinedValue() {
> > assertNull("An undefined argument should result in null",
> > multiplyAndAddFive(2, JSUNIT_UNDEFINED_VALUE));
> > }
> > </script>
> > </body>
> > </html>
When we run jsunit over http, we lose the "browse" button
(fileUpload). I think it's possible for us to write another kind of
"browse" button which can be used to browse both local and remote
files over http. I'm busy with something else; otherwise I'd like to
try it myself.
- Shujie
It is static. First, I don't think there is a way to use javascript to
crawl local directory. Second, junit is trying to do this which takes
too long time to do it and when there are too many test files it just
hangs itself. I just felt encouraged not to use it.
I think the "browse" is like "Start Menu" and the "list" is like
"Desktop". So it's ok when it's static. The reason we made this
enhancement is exactly the same reason as we need "Desktop".
- Shujie
So is this list of files just static in the main.html file and
maintained as you add new files? If not, could you post the code
that crawls the test directory looking for test files?
- Edward
--- In jsunit@y..., sd65@d... wrote:
> If you go to "Files", you can see a folder called testFileList.
There
> are two images files in it. It's our enhancement to jsunit. I'm
> wondering whether you are interested to incorporate it into jsunit
> package.
> The list is prepopulated. The file name path prefix has been taken
> care of. For local, you'll see /c|/..., or /d|/..., for remote,
> you'll see hostname:portnumber/path etc.
> You can also add/delete to/from the list, but the list is
initialized
> when you refresh the page.
>
> - Shujie
So I think what you are trying to do is to write a Test Page which
includes an ASP file on an IIS webserver in which your JavaScript is
defined. This ASP must produce a JavaScript file. That's fine - it
should work (although I've never seen an ASP which doesn't result in
an HTML page!).
Is that what you're trying to do? I think it is, except you say that
the page below IS test.asp, which confuses me. I think you mean that
the page below is just myTestPage.html or whatever and that it
includes test.asp. If so then my guess would be that something is
wrong with test.asp - could you post the source?
- Edward
--- In jsunit@y..., bnadesan@l... wrote:
> Can I test Javascript in an ASP page using JSUnit. I tried out
> something like this using JsUnit. It didn't work
> can please have a quick look at it. The Javascript is function
> multiplyAndAddFive() is in the test.asp.
>
> The function name:multiplyAndAddFive(-4, 5) is in Test.asp. The
> test.asp page is listed below......
>
> <!..test.asp-->
> <!--http://bn20785/AgentGUI/test.asp: where bn20785 is the
webserver--
> >
> <html>
> <head>
> <title>Test Page for multiplyAndAddFive(value1, value2)</title>
> <!-- note the asp in the src attribute--------------------->
> <script language="javascript"
> src="http://bn20785/AgentGUI/test.asp"></script>
>
> <script language="javascript" src="./app/jsUnitCore.js"></script>
> </head>
> <body>
> <script language="javascript">
> function testWithValidArgs() {
> assertEquals("2 times 3 plus 5 is 11", 11, multiplyAndAddFive
(2,
> 3));
> assertEquals("Should work with negative numbers", -15,
> multiplyAndAddFive(-4, 5));
> }
> function testWithInvalidArgs() {
> assertNull("A null argument should result in null",
> multiplyAndAddFive(2, null));
> assertNull("A string argument should result in null",
> multiplyAndAddFive(2, "a string"));
> }
> function testStrictReturnType() {
> assertNotEquals("Should return a number, not a string", "11",
> multiplyAndAddFive(2, 3));
> }
> function testWithUndefinedValue() {
> assertNull("An undefined argument should result in null",
> multiplyAndAddFive(2, JSUNIT_UNDEFINED_VALUE));
> }
> </script>
> </body>
> </html>
Anybody thought about running JSUnit under SVG (as an alternative to
HTML or WSH)?
One of my interests in JSUnit is testing DOM implementation of the
Adobe SVG viewer. Couldn't do a combo box without writing a lot of
event handling code, but could put a list of detected scripts with
hyperlinks.
The Adobe SVG viewer can be tested being driven from IE, however the
appeal of a pure SVG + JS implementation would be that it could also
be used to test the Apache Batik (SVG in Java) project.
I've been pretty pleased with SourceForge, the hard part is always
getting SSH to configured for those who have commit rights. I've
been done the path a few (well two) times and so I can help point out
the minefields.
The first is you have to make an irrevocable decision on the license
that under which the project will be conducted. If you want to
changes licenses, you have to abandon that project and start
another. You have choices most of the classic open licenses, GPL,
X11, Mozilla, etc. I'm not sure why JUnit used the IBM Public
License unless there was the involvement of an IBM employee. That
might be a reason to ask the JUnit project there recommendations on
licenses.
If you are developing under Windows (pretty likely in this case), you
will want to download the sfsetup project that will configure WinCVS
and SSH to access the SourceForge CVS.
If you go to "Files", you can see a folder called testFileList. There
are two images files in it. It's our enhancement to jsunit. I'm
wondering whether you are interested to incorporate it into jsunit
package.
The list is prepopulated. The file name path prefix has been taken
care of. For local, you'll see /c|/..., or /d|/..., for remote,
you'll see hostname:portnumber/path etc.
You can also add/delete to/from the list, but the list is initialized
when you refresh the page.
- Shujie
Can I test Javascript in an ASP page using JSUnit. I tried out
something like this using JsUnit. It didn't work
can please have a quick look at it. The Javascript is function
multiplyAndAddFive() is in the test.asp.
The function name:multiplyAndAddFive(-4, 5) is in Test.asp. The
test.asp page is listed below......
<!..test.asp-->
<!--http://bn20785/AgentGUI/test.asp: where bn20785 is the webserver--
>
<html>
<head>
<title>Test Page for multiplyAndAddFive(value1, value2)</title>
<!-- note the asp in the src attribute--------------------->
<script language="javascript"
src="http://bn20785/AgentGUI/test.asp"></script>
<script language="javascript" src="./app/jsUnitCore.js"></script>
</head>
<body>
<script language="javascript">
function testWithValidArgs() {
assertEquals("2 times 3 plus 5 is 11", 11, multiplyAndAddFive(2,
3));
assertEquals("Should work with negative numbers", -15,
multiplyAndAddFive(-4, 5));
}
function testWithInvalidArgs() {
assertNull("A null argument should result in null",
multiplyAndAddFive(2, null));
assertNull("A string argument should result in null",
multiplyAndAddFive(2, "a string"));
}
function testStrictReturnType() {
assertNotEquals("Should return a number, not a string", "11",
multiplyAndAddFive(2, 3));
}
function testWithUndefinedValue() {
assertNull("An undefined argument should result in null",
multiplyAndAddFive(2, JSUNIT_UNDEFINED_VALUE));
}
</script>
</body>
</html>
If we do move development to SourceForge, it would be just that - the
DEVELOPMENT would move there. The www.jsunit.net website and this
mailing list would all remain the same and I would still administer
them in the same way. To the user of JsUnit, nothing would change.
It's just that people working on developing the application would do
it through SourceForge (use CVS, mailing list for technical
development discussions, etc). In addition, I would be one of the
administrators for the SourceForge project. Don't worry, I won't let
anything bad happen to JsUnit - it's going to be a struggle just to
see my baby leave the nest to the SourceForge environment!
- Edward
--- In jsunit@y..., sd65@d... wrote:
> Thanks for the reply. Are there still going to be someone who will
be
> in charge of the publishing? I think as long as there is someone
who
> is willing to take care of the development and publish etc, it
> doesn't matter whether to put it into SourceForge or not;
otherwise,
> it would be a good idea to use SourceForge.
>
> - Shujie
Awesome. You're quite right - this technique works in Netscape 6.
It doesn't seem to work in IE, so we still have a different way of
collecting Test Function names in the two browsers, but this gets rid
of the need to define the "getTestFunctionNames()" in Netscape. I've
implemented this and created a new version of JsUnit - v1.2.3. It's
available for download now from the website.
Thanks a lot!
--- In jsunit@y..., sd65@d... wrote:
> Just did another research. The following code would give us all the
> test function names in NS.
>
> for(var i in window){
> if (i.search("test") == 0 && typeof(window[i]) == "function"){
> document.writeln(i + " is a test function name.");
> }
> }
>
> - Shujie
Just did another research. The following code would give us all the
test function names in NS.
for(var i in window){
if (i.search("test") == 0 && typeof(window[i]) == "function"){
document.writeln(i + " is a test function name.");
}
}
- Shujie
Thanks for the reply. Are there still going to be someone who will be
in charge of the publishing? I think as long as there is someone who
is willing to take care of the development and publish etc, it
doesn't matter whether to put it into SourceForge or not; otherwise,
it would be a good idea to use SourceForge.
- Shujie
Sounds perfect! I happened to start to do XP a couple of months ago.
It's not difficult to see that jsunit is done by an XPer. There's no
doubt that jsunit would become better and better.
- Shujie
I think we can use the following way to collect function names in NS.
It can even collect name of functions in an external js file and
right now I believe we can not do this in IE. I bet you know that
functions are attributes of window(frame) in NS. Did they change this
in NS 6.0? I would be surprised if they did.
The test page
=============
<html>
<head>
<title>Untitled</title>
<script language="JavaScript" src="functionC.js">
</script>
<script language="JavaScript">
function testA(){
}
function testB(){
}
</script>
</head>
<body>
<script language="JavaScript">
for(var i in window){
document.writeln(i + "=" + window[i] + "<br>");
}
</script>
</body>
</html>
functionC.js
============
function testC(){
}
The output
==========
length=0
frames=[object Window]
parent=[object Window]
top=[object Window]
self=[object Window]
name=
status=undefined
defaultStatus=
opener=null
closed=false
innerWidth=1020
innerHeight=618
outerWidth=1032
outerHeight=776
screenX=-4
screenY=-4
pageXOffset=0
pageYOffset=0
secure=false
frameRate=60
offscreenBuffering=auto
document=
history=undefined
location=file:///D|/Temp/nsFunctions.html
crypto=[object Crypto]
pkcs11=[object Pkcs11]
testC= function testC() { }
testA= function testA() { }
testB= function testB() { }
i=i
--- In jsunit@y..., sd65@d... wrote:
> Can't we use some way to collect test functions like in IE? I think
> all javascript function names are visible in NS.
>
> Shujie
You can't just ask for all the function names in a document (that I
know of, and believe me I've hunted for it - if you know how, let us
know!)
In IE, JsUnit asks a document for its "scripts", which means its
collection of <script> elements. Each script element is asked for
its contents, which is the JavaScript code. This code is parsed
for "function testXXX()", and the "testXXX"s are collected; these are
the test function names.
In Netscape 6, this mechanism isn't supported. So right now we're
getting around that by making the developer declare a function which
returns the test function names. It's a weakness of JsUnit...if
anyone can find a way, without using an applet or some such, to get
ahold of the contents of the Test Page, it would be great!
- Edward
One nice thing about developing a testing framework is that everyone
notices right away if there isn't a test for a feature. I'm pretty
happy that there are exhaustive unit tests for JsUnit (the ones that
come with JsUnit); whenever new features get added it's mandatory
that there be tests for the feature. In fact, the test really better
get written before the functionality, in the test-first XP
tradition. And of course, another XP thing that gets done when
development on JsUnit is in progress is to constantly run all the
tests, so no new feature should introduce problems with exisiting
functionality.
I don't want anyone to get caught up in worry that adding new
features or (especially) refactoring might introduce bugs or
instabilities -- please, be brave and rely on the tests. It was in
this way that we've gotten this far this fast.
I'm just reiterating XP ideas here. If you don't know what I mean by
XP (Extreme Programming), look here: http://www.xprogramming.org, and
read "Extreme Programming Explained" (Kent Beck).
- Edward
--- In jsunit@y..., sd65@d... wrote:
> I think it's nice to see more and more new features in jsunit. In
fact
> I really like the way jsunit is right now. It's compact, has the
basic
> features we need for javascript testing, and it works. We just
started
> to use it and really love it. I just hope that those new features
> won't prevent us from maintaining jsunit. Everyone knows the 80/20
> phenomenon.
>
> Shujie
On Wed, 23 May 2001 sd65@... wrote:
> Please excuse my ignorance, but what is the pros and cons to set up
> JsUnit development on SourceForge?
One potential advantage is that it will be easier to coordinate changes to
the source code. As more folks want to contribute patches, having it on
sourceforge, with a central CVS repository, will make that easier to
manage.
cheers
-- James
I think it's nice to see more and more new features in jsunit. In fact
I really like the way jsunit is right now. It's compact, has the basic
features we need for javascript testing, and it works. We just started
to use it and really love it. I just hope that those new features
won't prevent us from maintaining jsunit. Everyone knows the 80/20
phenomenon.
Shujie
Enter your vote today! A new poll has been created for the
jsunit group:
Should development JsUnit be set up on
SourceForge?
o Yes
o No
To vote, please visit the following web page:
http://groups.yahoo.com/group/jsunit/polls
Note: Please do not reply to this message. Poll votes are
not collected via email. To vote, you must go to the Yahoo! Groups
web site listed above.
Thanks!
[Earlier browser version support]
> Has there been a demand for this backward compatibility?
Yes, I have had interest in the past for a version which supports earlier
versions of Netscape and IE, although not a great deal - I've just always
thought of it as a hole in JsUnit.
[Running JsUnit on a webserver and storing your tests locally.]
> Vice versa seems the better option. However I personally have no need for
either option.
I would have thought that it would be more useful to have the latest install
of JsUnit on a webserver in an enterprise (or even on the web - imagine
hordes of developers the world over running tests at jsunit.net) and have
individual developers keep their own tests on their local machines; that way
they can run them whenever they like and JsUnit could be upgraded centrally.
[Nightly automation of test runs]
> This would be useful but not sure exactly how you could implement
> this...did you have an idea already on how?
I thought maybe we could implement a feature such that if you open your
browser not on testRunner.html but on testRunner.html?testSuite=foo.html
then as soon as JsUnit comes up it could run the test suite. Then a cron
job could just open a browser on that link and the window would be left up
for inspection the next morning (this is what we do where I work with some
of our very lengthy JUnit tests). Reporting results to a file or an email,
however, wouldn't be as easy. But take a look at the WSH version of JsUnit
on the website - that's more geared to command line use, and possibly
writing results to a file.
I'll set up a poll on moving JsUnit to SourceForge.
- Edward
Hi gang,
Some of the group suggestion questions may find benefit in having a
poll setup...but here are a few thoughts
--- In jsunit@y..., "Edward Hieatt" <edward@j...> wrote:
> There are currently several issues around JsUnit that need to be
discussed. Here are two technical ones:
>
> - We need to find a way to support browsers earlier than IE5.0+ and
Netscape 6+. Ideally I'd like to support Netscape 4.7+ and IE4.0+.
The problem is that these earlier browsers don't come with a version
1.4-compliant JavaScript engine, so we can't use exception handling.
A good deal of the core of JsUnit relies on exception handling - how
else can we deal with script errors and how else can we jump out of a
test as soon as we hit a failure? The only idea I have had is to do
something ugly such as to preparse Test Functions and create new
temporary ones with all kinds of logic inserted every other line.
>
Has there been a demand for this backward compatibility?
> - It would be nice to be able to save Test Pages on your local
drive and then run them in a browser in JsUnit served from a web
server. (Or maybe even vice versa?)
Vice versa seems the better option. However I personally have no need
for either option.
This is not currently possible due to JavaScript security
problems. From what I read we'd have to "sign" some of the scripts,
install certificates and the like. Is it worth the overhead? If we
did sign, I am told it would let us read files more easily, providing
a more graceful way of gathering Test Functions from a Test Page.
>
> And here are two more general questions:
>
> - Would people like to see JsUnit moved to SourceForge?
>
yes, that would be cool
> - Would people like to see automation of JsUnit runs? For example,
do you have a need want to run your master Test Suite automatically
every night?
>
This would be useful but not sure exactly how you could implement
this...did you have an idea already on how?
> - Edward
There are currently several issues around JsUnit that need to be discussed. Here are two technical ones:
- We need to find a way to support browsers earlier than IE5.0+ and Netscape 6+. Ideally I'd like to support Netscape 4.7+ and IE4.0+. The problem is that these earlier browsers don't come with a version 1.4-compliant JavaScript engine, so we can't use exception handling. A good deal of the core of JsUnit relies on exception handling - how else can we deal with script errors and how else can we jump out of a test as soon as we hit a failure? The only idea I have had is to do something ugly such as to preparse Test Functions and create new temporary ones with all kinds of logic inserted every other line.
- It would be nice to be able to save Test Pages on your local drive and then run them in a browser in JsUnit served from a web server. (Or maybe even vice versa?) This is not currently possible due to JavaScript security problems. From what I read we'd have to "sign" some of the scripts, install certificates and the like. Is it worth the overhead? If we did sign, I am told it would let us read files more easily, providing a more graceful way of gathering Test Functions from a Test Page.
And here are two more general questions:
- Would people like to see JsUnit moved to SourceForge?
- Would people like to see automation of JsUnit runs? For example, do you have a need want to run your master Test Suite automatically every night?