Getting started with QUnit

Source: Internet
Author: User

Getting started with QUnit

Recently, I like to use JUnit tdd on java, and the same is true for js. Previously, JQuery was good, so QUnit should be the most famous.

First, log on to the official website http://qunitjs.com/and download two files:

  • Qunit-1.15.0.js
  • Qunit-1.15.0.css

    In fact, the QUnit framework has these two things.

    Then write an html and a js according to getting started:

    <!DOCTYPE html> <meta charset="utf-8"> <title>QUnit Example</title> <link rel="stylesheet" href="//code.jquery.com/qunit/qunit-1.15.0.css"><body> <div id="qunit"></div> <div id="qunit-fixture"></div> <script src="//code.jquery.com/qunit/qunit-1.15.0.js"></script> <script src="tests.js"></script></body>

    Note: It is best to change the path

    <Linkrel = "stylesheet" href = "qunit-1.15.0.css">

    <Scriptsrc = "qunit-1.15.0.js"> </script>

    Otherwise, it may fail.

    Create a new tests. js file. Note that the name should not be wrong. I wrote test. js for a few minutes.

    QUnit.test( "hello test", function( assert ) { assert.ok( 1 == "1", "Passed!" );});

    Then you can see the test page:

     

  • 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.