前端单元测试插件qunit.js使用示例


<!DOCTYPE html>    
<html lang="en">    
<head>    
    <meta charset="UTF-8">    
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1, user-scalable=no">    
    <meta http-equiv=”X-UA-Compatible” content=”IE=edge,chrome=1″/>    
    <link rel="stylesheet" href="css/qunit-1.11.0.css">
    <script src="http://v3.faqrobot.org/hvb/com/js/jquery-1.11.3.min.js"></script>  
    <script src="js/qunit-1.11.0.js"></script>
    <title>test</title>    
    
    <style>    
        * {    
            margin: 0;     
            padding: 0;    
        }    
        body, html {    
            width: 100%;    
            height: 100%;    
        }    
           
  
    </style>    
</head>    
<body>    
    <h1 id="qunit-header">QUnit测试</h1>
    <h2 id="qunit-banner"></h2>
    <div id="qunit-testrunner-toolbar"></div>
    <h2 id="qunit-userAgent"></h2>
    <ol id="qunit-tests"></ol>
    <div id="qunit-fixture">测试标记</div>
    <input id="autocomplete" class="">
<script>
    /*$.ajax({
        url: 'http://v3.faqrobot.org/servlet/AQ?sysNum=1000000&s=p&jid=0&sourceId=2&_=1470647404706',
        dataType: 'jsonp',
        success: function(data) {
            var html = '';
            for(var i=0,len=data.topAsk.length; i<len; i++) {
                console.log(data.topAsk[i]);
                html += '<p>{question}</p>';
            }
            format($('.a').innerHtml, html)
        },
    });
    var x = format('my name is {name}', {
        name: 'hwb',
    });
    console.log(x);*/




    /*test("async测试", function() {
        stop();
        stop();
        $.ajax({
            url: 'http://v3.faqrobot.org/servlet/AQ?sysNum=1000000&s=p&jid=0&sourceId=2&_=1470647404706',
            dataType: 'jsonp',
            success: function(data) {
                equal(data.topAsk.length, 5);
                start();
            },
        });

        $.ajax({
            url: 'http://v3.faqrobot.org/servlet/AQ?sysNum=1000000&s=p&jid=0&sourceId=2&_=1470647404706',
            dataType: 'jsonp',
            success: function(data) {
                equal(data.topAsk.length, 5);
                start();
            },
        });
    });*/
    
    /*function A(name, age) {
        this.name = name;
        this.age = age;
    }
    A.prototype.addName = function() {
        this.name += this.name;
        return this.name;
    }
    A.prototype.addAge = function() {
        this.age += 1;
    }

    module('A类测试', {
        setup: function() {
            this.a1 = new A('hwb', 23);
        },
    });
     
    test("module的使用", function() {
        this.a1.addAge();
        equal(this.a1.age, 24);
        this.a1.addName();
        equal(this.a1.name, 'hwbhwb');
    });*/


</script>
</body>    
</html>


你可能感兴趣的:(前端单元测试插件qunit.js使用示例)