如何使用QUnit回调api
how to use QUnit Callbacks api
我正在学习如何使用QUnit、Javascript和html。到目前为止,我只知道如何使用一些Quit API,如OK()、equal()、notequal()、test()和expect(),但我很难理解如何使用Quit.done或Quit.log等回调。有人能给我举个例子吗?我下面有一些代码:
<head>
<title>My Tests</title>
<script src="jquery/jquery-2.1.0.min.js" type="text/javascript"></script>
<script src="qunitsrc/qunit-1.14.0.js" type="text/javascript"></script>
<link rel="stylesheet" href="qunitsrc/qunit-1.14.0.css" type="text/css" media="screen">
<script src="tests/calculator.js" type="text/javascript"></script>
<script src="tests/calculatortests.js" type="text/javascript"></script>
</head>
<body>
<h1 id="qunit-header">My Tests</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
calculator.js
function MathOperations(){
}
MathOperations.prototype.add = function(num1,num2)
{
var result = num1 + num2;
return result;
}
calculatortests.js
test("Add should add 2 items", function(){
var math = new MathOperations();
var result= math.add(1,2);
equal(result,3,"Result of 1+2 should be 3");
});
基本上,听起来您想使用这些回调编写自定义报告程序。有几个现有的可以作为你的基础。下面是一个JUnit兼容的XML报告程序示例:
https://github.com/jquery/qunit-reporter-junit
相关文章:
- MeteorJS:在带有回调的vzaar api上正确使用wrapAsync
- 回调函数中传递参数的困难(Google Map API Markers)
- 如何通过bxSlider回调api处理事件
- Google Data API上的OOP Javascript回调方法
- JavaScript回调函数和Google Feed API
- 谷歌放置了api回调解决方法
- 如何在node.js中通过API回调异步递归
- 承诺API回调-如何正确解决或拒绝
- 如何将自定义回调javascript参数添加到bing API回调中
- 获取API回调的参数
- 从iTunes搜索API回调返回值
- 返回NULL值的Google Geocode API回调函数
- 节点API回调与服务器websocket通信
- 如何发送JQuery实例方法作为Google API回调
- IE7和IE8的YouTube API回调
- Angularjs:我可以让我的指令在控制器API回调后运行吗?
- SoundCloud SDK/neneneba API回调事件未启动
- AngularJS在API回调后恢复表单
- 获取 API 回调以在 ReactJS 中的函数外部传递
- json-in-script"的Youtube API回调直通