Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7889777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:11:06+00:00 2026-06-03T06:11:06+00:00

I just started using YUI3 Test module (http://yuilibrary.com/yui/docs/test/). I have testcases with many asserts

  • 0

I just started using YUI3 Test module (http://yuilibrary.com/yui/docs/test/).

I have testcases with many asserts that verify state. If one of the assert fails, the TestConsole indicates an assert failed, but doesn’t indicate which of the many asserts in the test failed. It would be great to have the failure message report the line number.

The browser exception actually contains the JS failure line number, but the YUI3 Test class filters this out and throws its own exception, which doesn’t seem to contain the line number. Is there an easy way to add this reporting while still taking advantage of the YUI3 Test class as a harness??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T06:11:08+00:00Added an answer on June 3, 2026 at 6:11 am

    I will start with the tl;dr

    YUI3 does not provide any intrinsic way to display the line number of a failed test. I suppose it would be possible to manipulate Error constructors such that you could interrogate them; however, the problem is that Error.lineNumber is only supported in certain browsers (I believe it is Mozilla only).

    Even if that did work, you’d end up realizing that this is a bit convoluted. You’d have to always be sure to do:

    throw new Error*(...);
    

    In your calling code, you’d always have to do:

    try {...} catch(e) { /* e.lineNumber */ }
    

    And even if this all worked and you were willing to do this, I wouldn’t recommend it.

    The real answer

    The root of the problem is that you seem to have multiple Asserts in your test methods. Developers that are trying to be pragmatic will sometimes tell you that “one assertion per test method” is unreasonable and dogmatic. It is very attractive to think that multiple assertions per test method is fine…until it isn’t.

    I’m sure there are times where multiple assertions are better, but I haven’t seen it yet. I’ve been testing for years now and here is what I’ve found:

    1. I’ve given multiple asserts per method a try, and each time I’ve been bitten by the problem of not knowing which assertion failed. No cargo-culting here…I’ve tried both, and out of the two methodologies, only one has not bitten me.
    2. One assertion per test forces you to really think about what/how you are testing.

    Reading:

    • Testing: One assertion per test
    • One Assertion Per Test
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just started using Apache Commons StringEscapeUtils . According to http://www.w3schools.com/tags/ref_entities.asp , Ö should correspond
Have just started using Google Chrome , and noticed in parts of our site,
Have just started using Visual Studio Professional's built-in unit testing features, which as I
I just started using SVN, and I have a cache directory that I don't
I just started using the MVCContrib grid in a test project. I'm having a
This question is mostly just out of academic interest. I started using YUI 3
Just started using Blueprint CSS and now playing with the grids but have a
Just started using the Ace editor (http://ace.ajax.org) and although it works fine on a
I´ve just started using ASIHTTPRequest for iOs and I have a small issue with
I just started using Fabric to better control the specific settings for test and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.