qunit学习(一)

QUnit是一个强大的JavaScript单元测试框架,用于调试代码。该框架是由jQuery团队的成员所开发,并且是jQuery的官方测试套件。任意正规JavaScript代码QUnit都能测试。

其官方网站是:www.qunitjs.com

目前最新版本是1.14.

按照其官方网站的例子,现在后,放在resources目录下。并生成两个文件,分别是test.html和tests.js

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

这里需要注意一点,官方网站上,/resources前面,没有点,但是,调试时候发现,是需要.的。

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

运行后的界面是:

原文地址:https://www.cnblogs.com/aomi/p/3538175.html