????????????????????????????????????????????????б??????????????jUnit??cUnit??cppUnit??nUnit???????????xUnit???????????????????
?????????????
????????
???????????
??????????????????
????Javascript???????????????????????????????????????javascript??????б??淶??????????Qunit??YUI Test??JSTestDriver???????????????????÷?Χ
????Quint??jQuery???????????JQuery????е???????????????quit.css??qunit.js?????
????YUI Test???????????????????????YUI???е?????????????test??console????顣
????JSTestDriver?????????????д???????????javaScript??JSTD???????JAR??????????????????÷?????????????????????????????Щ??????н??в????
??????????????????YUI Test????Щ???????????????YUI??????????????While not a direct port form any specific xUnit framework?? YUI Test  does derive some characteristics form nUnit and jUnit????????????????xUnit?????????????nUint??jUnit???????Щ??????????????????????Щ??????????xUnit??????濴YUI Test???Щ?????
????Rapid creation of test cases through simple syntax-??ü????????????????????
????Advanced failure detection for methods that throw errors.- ???????????????????????????
????Grouping of related test cases using test suites.- ???????????????ò??????????
????Mock objects for writing tests without external dependencies.- ???mock??????????????????????
????Asynchronous tests for testing events and Ajax communication.- ?????????ajax??????????
????DOM Event simulation in all A-grade browsers-?????е?A????????е???????
????YUI Test???????????д???????????
????????YUI???
???????????test??console??or test-console????test-console??????????????????info??pass??fail??status??????????????????????3.5?汾???????
??????д????????
????????????????????
YUI({logInclude : { TestRunner: true }}).use("test"?? "test-console"?? "console"?? function (Y) {
var Test = {
drawConsole : function(){
var console = new Y.Test.Console({
newestOnTop : false??
filters: {
pass: true??
fail: true??
info: true
}
});
console.render('#testLogger');
}??
testBegin : function(){
var testCase1 = new Y.Test.Case({
name : "Data Tests"??
setUp : function(){
this.data = {
name : "test"??
year : 2007??
beta : true
};
}??
tearDown : function(){
if(this.data){
delete this.data;
}
}??
testName: function(){
var assert = Y.Assert;
assert.isObject(this.data);
assert.isString(this.data.name);
assert.areEqual("test"?? this.data.name);
}??
testYear : function(){
var assert = Y.Assert;
assert.isObject(this.data);
assert.isNumber(this.data.year);
assert.areEqual(2007?? this.data.year);
assert.areEqual("2007"?? this.data.year);
assert.areSame(2007?? this.data.year);
assert.areSame("2007"?? this.data.year);
}??
testBeta : function(){
var assert = Y.Assert;
assert.isObject(this.data);
assert.isBoolean(this.data.beta);
assert.isTrue(this.data.beta);
}
});
var testCase2 = new Y.Test.Case({
name : "Array Tests"??
setUp : function () {
this.data = [0?? 1?? 2?? 3?? 4];
}??
tearDown : function () {
if(this.data){
delete this.data;
}
}??
testPop : function () {
var Assert = Y.Assert;
var value = this.data.pop();
Assert.areEqual(4?? this.data.length);
Assert.areEqual(4?? value);
}??
testPush : function () {
var Assert = Y.Assert;
this.data.push(5);
Assert.areEqual(6?? this.data.length);
Assert.areEqual(5?? this.data[5]);
}??
testSplice : function () {
var Assert = Y.Assert;
this.data.splice(2?? 1?? 6?? 7);
Assert.areEqual(6?? this.data.length);
Assert.areEqual(6?? this.data[2]);
Assert.areEqual(7?? this.data[3]);
}
});
var testSuite = new Y.Test.Suite("Example Suite");
testSuite.add(testCase1);
testSuite.add(testCase2);
Y.Test.Runner.add(testSuite);
Y.Test.Runner.run();
}??
init : function(){
this.drawConsole();
this.testBegin();
}
}
Test.init();
});