Unit Tests for Extensions

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Unit Tests for Extensions

Dave Liebreich
Back in January, [Matt @
AllPeers](http://www.allpeers.com/blog/?page_id=61) sent me a pointer to
his unit test harness,
[foxunit](http://www.allpeers.com/blog/2005/09/28/foxunit-unit-test-framework-for-firefox/).
I finally got around to playing with it the other day, and I wrote a
[small set of simple unit
tests](http://people.mozilla.com/~davel/extension_unit/) for the [sample
extension](http://developer.mozilla.org/en/docs/Creating_a_status_bar_extension).
I even created a
[screenshot](http://people.mozilla.com/~davel/extension_unit/foxunit.png)
of the run results.

I liked how easy it was to create, edit, and run the tests - hitting
refresh reloaded the test files from disk, which is a big win. I also
liked looking at the failure output in the main browser window.

I ended up putting my setup code in the common section, because it
didn't work when I put it in the setup section. Matt has a note that
setup and teardown don't work right, and I guess that is what I was
tripping over.

I copied some of the code from jssh's debug helper file, mostly so that
I could run the tests in both jssh and foxunit.

Changes I'd like to see:

* use files, or a hierarchy of files, instead of xml, to hold the
javascript code. If I were to write lengthy test code, I'd probably cut
and paste it between the xml files and a code editor in js mode. Having
the js code in a separate file would eliminate this step.

* copy the assert function names used by xUnit test harnesses. If we
are going to have a number of test harnesses available, I'd like tests
to be as portable between them as possible.

* unattended run mode - a command-line switch that would read in a set
of tests, run them, write the results to a file, then exit. Perfect for
adding to a tinderbox test section, or other CI setup.
_______________________________________________
dev-quality mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-quality
Reply | Threaded
Open this post in threaded view
|

Re: Unit Tests for Extensions

Dave Liebreich
Ew.  So much for markdown looking ok in a newsgroup article.  Sorry
about that.

I'm going to take a stab at writing unit tests for the next sample
extension in the article series on MDC.

I'm wondering if anyone else is interested in working on this type of thing.

I'm also going to post a few more articles here in mdq describing the
other testing tools and harnesses I've seen.  Hopefully, we can have an
active discussion here and write some tests to run in these harnesses too.

-Dave
_______________________________________________
dev-quality mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-quality
Reply | Threaded
Open this post in threaded view
|

Re: Unit Tests for Extensions

beaufour@gmail.com
> I'm wondering if anyone else is interested in working on this type of thing.

You bet :)

As you know I've been hacking testing in my part of the Mozilla world
(XForms). I have some of my "test harness" online here:
http://beaufour.dk/xftst/
There are README files that (hopefully) explains how it works. (trunk
jsunit testing is broken right now though...)

... Allan

_______________________________________________
dev-quality mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-quality
Reply | Threaded
Open this post in threaded view
|

Re: Unit Tests for Extensions

Dave Liebreich
[hidden email] wrote:
>> I'm wondering if anyone else is interested in working on this type of thing.
>
> You bet :)

Hi Allan,

I've not forgotten about you :-)

I'm hoping to gather in this newsgroup folks who are working on test
tools - to that end, I'll be contacting people directly and doing some
cross-posting.

But first, we (the moco qa team, of which I am part) need to get
Thunderbird 1.5.0.2 out the door.

Please feel free to invite folks you know to discuss testing issues here.

--
Dave Liebreich
Test Architect, Mozilla Corporation
_______________________________________________
dev-quality mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-quality
Reply | Threaded
Open this post in threaded view
|

Re: Unit Tests for Extensions

Dave Liebreich
Dave Liebreich wrote:

> But first, we (the moco qa team, of which I am part) need to get
> Thunderbird 1.5.0.2 out the door.

And Firefox 1.5.0.3 - sorry for not posting anything more on the tests
and test harnesses.  I'm hoping to get some stuff written down today or
over the weekend.

--
Dave Liebreich
Test Architect, Mozilla Corporation
_______________________________________________
dev-quality mailing list
[hidden email]
https://lists.mozilla.org/listinfo/dev-quality