Re: Request for Feedback On Test Harness

On Nov 30, 2010, at 20:57, Maciej Stachowiak wrote:

> I wrote a script test and found myself stymied by this design choice.

Me, too.

> I wanted my test output to report each assertion that passed or failed individually. It seems like the only way to do this is to use a separate test() and assert_equals() for each assertion, for example:
> 
>     test(function() {
>         assert_equals(document.getElementById("abcd"), document.getElementsByTagName("i")[0]);
>     }, "User agents must associate the element with an id value for purposes of getElementById.");

I had exactly the same experience.

> A) Add a test_assert_equals() combo call (perhaps the shorthand should even take an expression to eval rather than a function, but it doesn't really matter). That way, you can easily have a list of assertions each of which is reported independently, with a useful error message that reports the bad value.

I was tempted to write one and call it ok(). :-/

However, if people start writing their non-assertion code outside a test() wrapper, isn't the whole point of the test() wrapper defeated and onerror becomes necessary anyway?

-- 
Henri Sivonen
hsivonen@iki.fi
http://hsivonen.iki.fi/

Received on Wednesday, 1 December 2010 13:09:22 UTC