??????????????????????
???????????? ???????[ 2015/6/26 15:13:24 ] ??????????????? ???????
????1.?????????????
???????????????????????????????????????????????械?
?????????????????????????????console?????????????????????????????????椋�?鈥参�????????????????效?????????????????写????????????????????伪?写?????????
????????????????????????????????????????????????????谢??婕�????????些API??????????????????????些API?????????????????????????????????????????????
????????????????????????????????????????????????????????????????????????????????API??????TDD???????????????????????
?????????????????????????????????????????????????????????????????????????????????????胁??????????????????????????
????2.????????????????
????2.1??????
?????????????????????QUnit??jasmine??mocha??jest??intern???????些????????????????锟�???????????????芯???
????Qunit:???????????????jquery???????????????????????????????jquery????????????????????????jquery?????
????jasmine:Behavior-Drive development(BDD)????????????????????校????????妫�???asssert??mock????
????mocha:node????????tj?????????????node??browser?????????泻???????????????????????????????????????report
????intern:?????????貌?????????????妫�????????????????????????泄???
????2.2?????
????chai??????????????械???????????TDD(assert)??BDD(expect??should)????????????
????var chai=require('chai');
????var assert=chai.assert;//typef assert==='object'
????chai.should();//??Obejct.prototype???????
????should.js:TJ????????????????
????expect.js:BDD????????????????????should.js????mini???BDD??
????assert(node??????????):??????node????????????
????2.3 mock??
????????????????mock?????????????????????????椋�????些?????????????些??????绮�???????????????????危????????????????????????椋�???????????????????mock?????伪??????????椤�?????????XMLHttpRequest?????????http statusCode?404????????????????????????????????mock?????????
????sinon.js:???????mock????????spies??stub??fake XMLHttpRequest??Fake server??Fake time???????????????????????
????2.4 test runner
????karma:???貌???????????????????????????????????????????????????胁????
????3.??????????????????
????????????卸????????????????????console???????text???
???????????actual???expect???????????????????????????????????????些?????????????????????????????????????????????????????
????mock??????????????渭??????????????????????????????????????o?????????些??????????????called??calledWithArguments?????
????function describe(text??fn){
????try{
????fn.apply(...);
????}catch(e){
????assert(text)
????}
????}
????function fn(){
????while(...){
????beforeEach();
????it(text??function(){
????assert();
????});
????afterEach();
????}
????}
????function it(text??fn){
????...
????fn(text)
????...
????}
????function assert(expect??actual){
????if(expect not equla actual){
????throw new Error(text);
????}
????}
????function fn(){
????...
????}
????function spy(cb){
????var proxy=function(){
????...
????}
????proxy.called=false;
????proxy.returnValue='...';
????...
????return proxy;
????}
????var proxy=spy(fn);//??????mock????
????4.???写???????????
????4.1???
???????????????????????????????????
??????????????????????????????
?????????????????????
???????????????????????????
????????AOP(beforeEach??afterEach)?????????????????????????霉???
?????????????????????????????????????
????4.2 TDD
??????浠�???????????写???????写????????TDD??????????????????????????????????????????????????????????????????????宥�?????????;
????????????TDD???????????????????????????????????????????????????锟�??????????????TDD???????????????????????写?????????????????????????????????????????????泻?????????????????????????写?????????????????????TDD????????????谩?
????4.3 BDD
?????????????????????????????????????????????????????QA?????????????协????BDD???????????????????????????(????GUI)?????贸?????????.
??????

???路???
??????????????????
2023/3/23 14:23:39???写?貌??????????
2023/3/22 16:17:39????????????????????些??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???路???????路
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11