内容简介

  《Python测试驱动开发(影印版英文版)》这本实用指南带你从头至尾经历一个真实Web应用开发的全过程,展示了Python测试驱动开发(TDD)的优越性。你将学到如何在应用程序各部分被构建出来之前就编写并运行测试,然后开发*少量的代码就让这些测试运行通过。结果得到什么?能够运行的简洁代码。
  在书中,你将学到Diango、Selenium、git、iQuery和Mock的基础知识,另外还有现代Web开发技巧。如果你准备将自己的Python技术提升到下一个层次,《Python测试驱动开发(影印版英文版)》清楚地展示了测试驱动开发是如何提倡简单设计并增进信心。
  深入测试驱动开发工作流,包括单元测试/编码周期循环和重构为类和函数使用单元测试,并为浏览器内的用户交互使用功能测试学习何时与如何运用mock对象,以及单独和集成测试的优缺点在开发用服务器上测试以及自动化部署将测试运用到网站集成的第三方插件上去使用一个持续集成环境来自动运行测试

目录

Preface
PrerequisitesandAssumptions
CompanionVideo
Acknowledgments
PartI.TheBasicsofTDDandDjango
1.GettingDjangoSetUpUsingaFunctionalTest
ObeytheTestingGoat!DoNothingUntilYouHaveaTest
GettingDjangoUpandRunning
StartingaGitRepository

2.ExtendingOurFunctionalTestUsingtheunittestModule
UsingaFunctionalTesttoScopeOutaMinimumViableApp
ThePythonStandardLibrary'sunittestModule
Implicitwaits
Commit

3.TestingaSimpleHomePagewithUnitTests
OurFirstDjangoApp,andOurFirstUnitTest
UnitTests,andHowTheyDifferfromFunctionalTests
UnitTestinginDjango
Django'sMVC,URLs,andViewFunctions
AtLast!WeActuallyWriteSomeApplicationCode!
urls.py
UnitTestingaView
TheUnit-Test/CodeCycle

4.WhatAreWeDoingwithAllTheseTests?
ProgrammingIslikePullingaBucketofWaterupfromaWell
UsingSeleniumtoTestUserInteractions
The"Don'tTestConstants"Rule,andTemplatestotheRescue
RefactoringtoUseaTemplate
OnRefactoring
ALittleMoreofOurFrontPage
Recap:TheTDDProcess

S.SavingUserInput
WiringUpOurFormtoSendaPOSTRequest
ProcessingaPOSTRequestontheServer
PassingPythonVariablestoBeRenderedintheTemplate
ThreeStrikesandRefactor
TheDjangoORMandOurFirstModel
OurFirstDatabaseMigration
TheTestGetsSurprisinglyFar
ANewFieldMeansaNewMigration
SavingthePOSTtotheDatabase
RedirectAfteraPOST
BetterUnitTestingPractice:EachTestShouldTestOneThing
RenderingItemsintheTemplate
CreatingOurProductionDatabasewithmigrate

6.GettingtotheMinimumViableSite
EnsuringTestIsolationinFunctionalTests
RunninglusttheUnitTests
SmallDesignWhenNecessary
YAGNI!
REST
ImplementingtheNewDesignUsingTDD
IteratingTowardstheNewDesign
TestingViews,Templates,andURLsTogetherwiththeDjangoTestClient
ANewTestClass
ANewURL
ANewViewFunction
ASeparateTemplateforViewingLists
AnotherURLandViewforAddingListItems
ATestClassforNewListCreation
AURLandViewforNewListCreation
RemovingNow-RedundantCodeandTests
PointingOurFormsattheNewURL
AdjustingOurModels
AForeignKeyRelationship
AdjustingtheRestoftheWorldtoOurNewModels
EachListShouldHaveItsOwnURL
CapturingParametersfromURLs
Adjustingnew_listtotheNewWorld
OneMoreViewtoHandleAddingItemstoanExistingList
BewareofGreedyRegularExpressions!
TheLastNewURL
TheLastNewView
ButHowtoUseThatURLintheForm?
AFinalRefactorUsingURLincludes

PartII.WebDevelopmentSineQuaNons
7.Prettification:LayoutandStyling,andWhattoTestAboutIt
8.TestingDeploymentUsingaStagingSite.
9.AutomatingDeploymentwithFabric
10.InputValidationandTestOrganisation
11.ASimpleForm
12.MoreAdvancedForms
13.DippingOurToes,VeryTentatively,intoJavaScript
14.DeployingOurNewCode

PartIII.MoreAdvancedTopics
15.UserAuthentication,IntegratingThird-PartyPlugins,andMockingwithJavaScript.
16.Server-SideAuthenticationandMockinginPython
17.TestFixtures,Logging,andServer-SideDebugging
18.Finishing"MyLists":Outside-InTDD
19.TestIsolation,and"ListeningtoYourTests".
20.ContinuousInteoration(CI)
21.TheTokenSocialBit,thePagePattern,andanExercisefortheReader
22.FastTests,SlowTests,andHotLava..

ObeytheTestingGoat!
A.PythonAnywhere
B.DjangoClass-BasedViews
C.ProvisioningwithAnsible
D.TestingDatabaseMigrations
E.Behaviour-DrivenDevelopment(BDD)
F.CheatSheet
G.WhattoDoNext
H.Bibliography
Index

其他推荐