On Oct 14, 11:24 pm, "Jörn Zaefferer" <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I'm currently gathering idea for further improvements for QUnit
> (http://docs.jquery.com/QUnit). One source of inspiration is
> ScrewUnit:http://github.com/nkallen/screw-unit/tree/master
> The point isn't to replicate ScrewUnit, but I'd like to get some
> feedback on what features could fit well into QUnit. That page
> actually contains quite decent documentation, so you're welcome to
> take a look and give some feedback on what you'd like to see in QUnit.
>
> If you have some tests that are rather painful to write/read, please
> share them, looking at ways to improve readability and
> ease-of-writing.
>
> I want to keep QUnit focused on testing jQuery, jQuery UI and plugins
> based on them, so this is a good chance to influence the future
> development.
>
> Regards
> Jörn

Hello

I just started using QUnit for a project I'm working on and I noticed
that there is no easy way to test code that should throw exception
when it fails. It can be worked around with expect() or ok() with a
boolean variable, but it's far from DRY.

So, I would like to see support for expected exceptions. Here is my
implementation for illustrative purposes:

/**
 * Asserts an exception has been thrown
 * @example fails( function() { throw new Error(); }, "Error",
"Throwing code should throw Error" )
 */
function fails(callback, error, msg) {
    var thrown = false;

    try {
        callback();
    } catch ( e if ( e.name == error || e == error ) ) {
        thrown = true;
    }

    config.Test.push( [ thrown, msg ] );
}

The code works in Firefox 3.0 but I'm not sure how well catch..if is
supported across different browsers.

Regards

--
Damir Zekić

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to