没有合适的资源?快使用搜索试试~ 我知道了~
programming-openresty
需积分: 10 10 下载量 50 浏览量
2017-12-29
12:42:13
上传
评论
收藏 501KB PDF 举报
温馨提示
试读
73页
programming-openresty, nginx,lua ,programming-openresty, nginx,lua ;
资源推荐
资源详情
资源评论
ProgrammingOpenResty
ThisisanofficialguideonOpenRestyprogrammingwrittenbytheOpenRestycreator.This
bookisstillinpreparation.Pleasecheckbackoftenforupdates.
TheentireProgrammingOpenRestybook,writtenbyYichunZhang,isavailablehere.All
contentislicensedundertheCreativeCommonsAttributionNonCommercialShareAlike
3.0license.Youcandownloadorbrowsetherenderedbookinvariousdifferentformatson
theGitBookwebsitebelow.
https://www.gitbook.com/book/openresty/programming-openresty/
ThelatestsourceofthebookcanbefoundinthefollowingGitHubrepository:
https://github.com/openresty/programming-openresty
Pullrequestsarealwayswelcome.
Introduction
2
AutomatedTesting
Automatedtestingplaysacriticalroleinsoftwaredevelopmentandmaintainance.
OpenRestyprovidesadata-driventestscaffoldforwritingdeclarativetestcasesforNGINX
Cmodules,Lualibraries,andevenOpenRestyapplications.Thetestcasesarewrittenina
specification-likeformat,whichisbothintuitivetoreadandwriteforhumansandalsoeasy
tohandleformachines.Thedata-drivenapproachmakesiteasytorunthesametestsin
wildlydifferentwaysthatcanhelpexposeissuesindifferentscenariosorwithdifferentkinds
ofexternaltools.
ThischapterintroducestheTest::Nginxtestscaffoldthathasbeenwidelyusedtoorganize
testsuitesforalmostalltheOpenRestycomponents,includingthe ngx_http_luamodule,
mostofthe lua-resty-*Lualibraries,aswellasfull-blownbusinessapplicationslike
CloudFlare’sLuaCDNandLuaSSL.
Keywords:Testing,Mocking
AutomatedTesting
3
Introduction
OpenRestyitselfhasbeenrelyingonautomatedtestingtoremainhighqualityoverthe
years.AsOpenRestycoredevelopers,weembracethetestdrivendevelopment(TDD)
processallthetime.AnexcellentresultofourTDDpracticesovertheyearsisahugesetof
testsuitesforalltheOpenRestycomponents.Thesetestsuitesaresolargeasawhole,so
itisimpracticaltorunalltheteststhoroughlyonasinglemachine.Arelativelylargetest
clusterisoftenrunonAmazonEC2torunallthesetestsinallexistingtestmodes.Lyingat
theheartofthesetestsuitesisusuallytheTest::Nginxtestscaffoldmoduledevelopedby
theOpenRestyteam.
The Test::Nginxscaffoldprovidesagenericsimplespecificationlanguageforexpressing
andorganizingtestcasesinanintuitiveway.Italsoprovidesvariouspowerfultestingmodes
or"engines"torunthetestsinvariousdifferentwaysinthehopeofexposingbugsin
differentsettings.Itisalsosupportedtoextendthetestspecificationlanguagetoaddcustom
abstractionsforadvancedtestingneeds,usuallyfoundinapplication-levelregression
testing.
ConceptualRoadmap
Overview
Introduction
4
Test::Nginx
Test::Nginxisatestframeworkthatdrivestestcaseswrittenforanycoderunningatop
NGINX,andalso,naturally,theNGINXcoreitself.ItiswritteninPerlbecauseoftherich
testingfacilitiesandtoolchainalreadyaccumulatedinthePerlworldforyears.Fortunately,
theuserdoesnotreallyneedtoknowPerlforwritingtestcasesatopthisscaffoldsince
Test::Nginxprovidesaverysimplenotationtopresentthetestcasesinaspecification-like
format.
Thesimpletestspecificationformat,orlanguage,usedinTest::Nginxisjustadialectof
themoregeneraltestinglanguageprovidedbytheTest::BasetestingmoduleinthePerl
world.Infact, Test::NginxisjustasubclassofTest::Baseinthesenseofobject-oriented
programming.Thismeansthatallthefeaturesofferedby Test::Baseisavailablein
Test::Nginxand Test::Nginxjustprovideshandyprimitivesandnotationsthatsimplify
testingintheNGINXandOpenRestycontext.Thecoreideaof Test::Baseissousefulthat
wehavebeenusingtestingscaffoldsbasedonTest::Baseinmanydifferentprojectseven
includingHaskellprogramsandLinuxkernelmodules.Test::Nginxissuchanexamplewe
createdfortheNGINXandOpenRestyworld.Detaileddiscussionofthe Test::Base
frameworkitselfisbeyondthescopeofthisbook,butwewillintroducetheimportant
featuresof Test::BasethatareinheritedbyTest::Nginxinthelatersections.
Test::NginxisdistributedviaCPAN,theComprehensivePerlArchiveNetwork,justlike
mostoftheotherPerllibraries.Ifyoualreadyhaveperlinstalledinyoursystem(many
Linuxdistributionsshipwithperlbydefault),thenyoucaninstall Test::Nginxwiththe
followingsimplecommand:
cpanTest::Nginx
Forthefirsttimethatthecpanutilityisrun,youmaybepromptedtoconfigurethe cpan
utilitytofityourrequirements.Ifyouareunsureaboutthoseoptions,justchoosethe
automaticconfigurationoption(ifavailable)orjustacceptallthedefaultsettings.
Test::Nginxprovidesseveraldifferenttestingclassesfordifferentuserrequirements.The
mostfrequentlyusedoneisTest::Nginx::Socket.Therestofthischapterwillfocusonthis
testingclassanditssubclasses.WewillusethenamesTest::Nginxand
Test::Nginx::Socketinterchangeablyfromnowontomeanthe Test::Nginx::Sockettest
moduleanditssubclasses,unlessotherwisespecified.
Test::Nginx
5
剩余72页未读,继续阅读
资源评论
xiaomantoubaba
- 粉丝: 68
- 资源: 18
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功