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.cssIn 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: