- From: Simon Pieters <simonp@opera.com>
- Date: Wed, 02 Apr 2014 10:30:35 +0200
- To: "public-test-infra@w3.org" <public-test-infra@w3.org>, "James Graham" <james@hoppipolla.co.uk>
On Wed, 02 Apr 2014 00:07:49 +0200, James Graham <james@hoppipolla.co.uk>
wrote:
> So one request I've had from people at Mozilla used to writing
> Mochitests is an easier way to write testharness.js tests, particularly
> for the special case where there is exactly one test per file. This is a
> interesting case because the file itself provides the isolation that we
> usually try to obtain by wrapping each test step in a function() {}, so
> it is possible to cut out some of the verbosity. An example of the kind
> of result we might get is
>
> <doctype html>
> <title>Example test</title>
> <script src=/resources/testharness.js></script>
> <script src=/resources/testharnessreport.js></script>
> <script>
> setup({file_is_test:true})
>
> onload = function() {assert_true(true); done()}
>
> I think there are some possible disadvantages to this; in particular it
> might encourage people to put a whole load of things that should be
> separate tests as multiple asserts in one file in a way that will break
> if one assert doesn't work in a particular browser. However it does seem
> like if used wisely it could be a win, and might help sell the idea of
> writing testharness.js tests going forward at Mozilla. What do people
> think?
I think it's a good idea. But it would be nice to minimize the boilerplate.
The snippet above omits <div id="log"></div> which is currently required,
but the script could create it if it's missing.
It would be nice to avoid the setup({file_is_test:true}). Maybe the script
can figure it out based on what's called first: test/async_test or
assert_foo/done ?
--
Simon Pieters
Opera Software
Received on Wednesday, 2 April 2014 08:30:06 UTC