欢迎来到天天文库
浏览记录
ID:41408773
大小:77.46 KB
页数:8页
时间:2019-08-24
《使用Specs进行单元测试-Java开发Java经验技巧》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、E,OASpecs^0DDp¥da2aEd・JavaJCJava^NeWAQEEiOASpecs^DDinYO^aEd±^IAOEImportNew・O1I°I6UOexOScalaSchooljMO^OEe-OeDixei£xaO0Qe%uIAA©da^o;£Oa^dA^UMAAUEY^^E^ASpecs^DD^EOI-iI-iEi^eEUAEScalapADDFQyll~Ee%2E(Behavior-DrivenDesingBBD)pA^o%Ui£•%I3DSpecificationoAUQ^
2、IE^Ay•O^DDA£DI•»%3pAEeOAOeQaAiodoFirstodoBeforeodoAfteromustEqualo°ii°-i4X"••••XoEyA^EIIaH?o±aDXxo%°pA/E¥Aa^•Mock•Spies•OUsbtODOEDD^FDSpecificationEAIOA^O土%O『E%oE!importorg•specsobjectArithmeticSpecextendsSpecification{nArithmetic”should{11addtwonumbe
3、r's”in{1+1mustEqua丄2}11addthreenumbers11in{1+1+1mustEqual3^^E(;d»5dEnAiAi£z仝仝、addtxvonumbers°Iaddthreesnumber^'AEQE3AAy£、Xz✓mustEqua丄土〃(匕xp(?C/a〃62丿6UAad^dyiaE%DZ2aE6d®Q°£-imustEquaiid»EQAapA^t7/wpAd»5dO%i»ui£Eu6DpAE%Ay(example)xiEUda6Dd»56^UIufexpec
4、tation)^O0/x^daOUA^^aEOOAAypAAu^OD^^ODadciiHdAQiEddf^yn/xM^UIuCexpectation)AxIu3yd0/pAAuAuj£importorg•specsobjectArithmeticSpecextendsSpecification{nArithmetic”should{"add*'in{ntwonumbers0in{1+1mustEquai2}"threenumbers11in{1+1+1mustEquai3}}}}6DDA£DIob
5、jectExecSpecextendsSpecification{nMutationsareisolated11should{varx=011xequals1ifwesetit•”in{xmustEqum丄1}nxisthedefaultvalueifwedon11changeitHin{xmustEqual0}OAAy
6、LiAEedA(Setup)6e^aAi(Teardown)doBefore°IdoAfter,fmysystem11should{doBefore{resetTheSystem
7、()/**user-definedresetfunction*/}nmessupthesystem”in{•••}nandagain11in{•••}doAfter{cleanThingsUp()}}xQddoBefore/doAfterd»»adUO(
8、
9、x6E%Ay£,,leafexample£©EIOEDDj£doFirst°IdoLastdoFirst/doLastO^6a6A6ud»zIDd
10、jAEedAi££-DedaE%(][Ad£-i2»1yid2»E16AEuAQ£©,fFool
11、fshould{doFirst{openTheCurtains()}"teststatelessmethods11in{•••}ntestotherstatelessmethods11in{•••}doLast{closeTheCurtains()}}^¥Aa^v(Matchers)AaODd^OE^Yf-i^^dled^ednEuEQndyEjflOA^^EddE^AmatcheriflAAaeidA^A77Z3£OA
12、jAd»D©matcheri££-2Ii%/E¥Aa^diAT£©mustE
13、qualldA^oAaedN%%u1yd»D©E16AmustEqualpAAyx6i£1mustEqual1nal!mustEquel,falfiEOOADTIldyOA^dBdpEQnial-iifDdADAipAdpvalnumbers=List(1,2Z3)numbersmustcontain(1)numbersmustnotcontain(4)numbersmustcontainAll(List(1,2,3))numbersmustcontainInOrder(List(
此文档下载收益归作者所有