JavaScript refactoring (III): JavaScript Testing

Source: Internet
Author: User
During JavaScript refactoring, I hope to introduce an easy-to-use testing framework to ensure smooth refactoring. In the future, I will continue to use the testing code to ensure the correctness of the JavaScript logic. JsUnit (http://sourceforge.net/projects/jsunit/,http://www.jsunit.n...

During JavaScript refactoring, I hope to introduce an easy-to-use testing framework to ensure smooth refactoring. In the future, I will continue to use the testing code to ensure the correctness of the JavaScript logic.
Http://sourceforge.net/projects/jsunit/,http://www.jsunit.net/ (JsUnit)
JsUnit is an independent JavaScript unit testing framework, which is similar to JUnit and has no difficulty in getting started, including the traditional setUp and tearDown methods. The assert method provided is similar to JUnit, besides the JavaScript-specific methods such as assertNaN and assertUndefined. The test page must be inIntroduce the jsUnitCore. js file.
Test Suite support: Provides addTestPage and addTestSuite;
Test log support: it includes three log levels: warn, info, and debug. The front-end code is not similar to the background code. Too many logs should not be used in the official code. Besides, log is only supported under FF.
 
The following is an example:
Js Code

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.