Professional Documents
Culture Documents
JoelChampagne
President,CodeX President CodeX Enterprises
July2011
MarkGinnebaugh,UserGroupLeader, mark@designmind.com mark@designmind com
WhoamI? Who am I?
President CodeX Enterprises LLC PresidentCodeX EnterprisesLLC 20yearsconsultingexperience
L Largemissioncriticalsystems i i iti l t .NET,SQL20002008,SSAS,SSRS,SSIS Architecture,DataArchitecture
Focusondeveloperproductivitytools
Why?
UnitTestingwhatsaunit? U it t ti h Unittestinghasprovenvaluableinmany l bl i languages Things can break for countless reasons find Thingscanbreakforcountlessreasons find thosebreakagesearly SomemaysaySQLhasgottentheshortendof thestickhereforvariousreasons h i kh f i
Harder:time/efforttowritetestsforpossibly thousandsofobjects(manyofwhichcouldbeCRUD) j ( y ) Separationofdevelopmentprocess Statefulness:dependenceonspecificdatatomakeit fly(well) fly (well)
Automation
Includesonchange ContinuousIntegrationstrategies
Observations
Quitepowerfulaswecancraftdatadriven testsusingabitofC# tests using a bit of C#
NotnecessarilytestingSQLdirectly(canbe.NET components) p ) Nextslideexample
Datadrivenexample
SQLHero
Problemstryingtoaddress:
Developersoftendontliketoinvesttimeinwritingtests
At least get some touch testsasastartingpoint Atleastgetsome touchtests as a starting point
Wanttoexercisetestsearlyandoften!
OnALTERandscheduled(andondemand)
L Leveragetestswedohaveatstrategictimes:e.g.scripting d h i i i i changestoanewplace
Canincludetheseautomaticallyfromtheschemacomparetool!
Settingoftargets,notjustthresholds(sowecando reporting/analysisvs.targets) Tests can be somewhat portable(i.e.donotneedto Testscanbesomewhat portable (i.e. do not need to strictlytietoasingledatabase) Realityofdatabaseswithhundredsoftables,reference data,etc. maynotbepracticaltoregentheentirething data etc may not be practical to re gen the entire thing fromscripts,etc.
Configuration g
TestingPolicies.xml
Example:aproc parameterthatendsinAreaID,populateusingaselectfromAreatablethatisfiltered <PARAMETER> <PATTERN>AreaID$</PATTERN> <SQL_LOOKUP>SELECTAreaID FROMAreaaWHEREa.AreaAbbr LIKE'A%'</SQL_LOOKUP> / </PARAMETER> Example:aproc parameterof@DocTypeID thatrelatestoatablecalledCommDocumentType <PARAMETER> PARAMETER <NAME>@DocTypeID</NAME> <CHANGE_NAME_TO>CommDocumentType</CHANGE_NAME_TO> </PARAMETER> Example:asampleplugin,putintheprogramfiles\sqlhero\pluginsdirectory <PLUGIN> <ASSEMBLY_FILE>SampleTestingPlugIn.dll</ASSEMBLY_FILE> <TYPENAME>SampleTestingPlugIn.MyTestPolicy</TYPENAME> </PLUGIN> Example:allobjectsintheDebugschemawouldbeexcludedfromtesting <OBJECT> <PATTERN>^\[?Debug\]?\.</PATTERN> <IS_EXCLUDED>True</IS_EXCLUDED> </OBJECT>
Notes
The test generation process will look at Thetestgenerationprocesswilllookat capturedworkloadstoseeifanalready executedinvocation willwork executed invocation will work Isusingarandomizedprocess,butinfluenced bytestingpolicyfile by testing policy file Nosideeffects
Rollbackperobject Advantages/Disadvantages
CreatingTests g
SomeObservations
Presenceoftouchtestinghasprovenvaluefrom experience experience example SQLHerotestingcanaugmentVStesting:
VSforformalunittestswhicharepartofbuild process,complexcaseswherecanuseC# SHfortouchteststhatarejusttherebehindthe scenestofindcertainissuesforyoutransparently y p y OutputofSHtestingtemplatecanbeusedinVS,if youlike!
Not intending SQL Hero to do it allbut NotintendingSQLHeroto doitall but consideringsomenewfeaturesalongthelinesof turningcapturedworkloadsintocomplextest cases(C#) ( )
SomeObservations
Presenceoftouchtestinghasprovenvaluefrom experience experience example SQLHerotestingcanaugmentVStesting:
VSforformalunittestswhicharepartofbuild process,complexcaseswherecanuseC# SHfortouchteststhatarejusttherebehindthe scenestofindcertainissuesforyoutransparently y p y OutputofSHtestingtemplatecanbeusedinVS,if youlike!
Not intending SQL Hero to do it allbut NotintendingSQLHeroto doitall but consideringsomenewfeaturesalongthelinesof turningcapturedworkloadsintocomplextest cases(C#) ( )
Amorecomplexusecase p
Problemstryingtoaddress:
Dataqualityindevelopmentregions Securityandisolationofproductiondata Inprogresswork(usingexternalsourcecontrol?) Makingthiseasy Making this easy
Howdoesunittestingrelate?
Integratedaspartoftheprocesstoensurethingsstill workattheend(couldbeadifferentprocesstoo) work at the end (could be a different process too) Overallprocesscanserveasonewaytoachievethe covetedknownstartingpoint easily
Amorecomplexusecase illustrated
Production QA/Development
Prod (remote)
QANew Backup
QA
QANew (remote)
Scramble sensitive data
Remove
Amorecomplexusecase illustrated
Production QA/Development
Prod (remote)
QANew Backup
QA
QANew Backup
Restore
FTPLanding Zone
QANew
Performtests
Amorecomplexusecase illustrated
Production QA/Development
Prod (remote)
QAOld
QA
Puttingittogether
VS Database Project VSDatabaseProject
Build>Deploy(localorshared) Canexercisestaticcodeanalysis Canincludeunittesting Can include unit testing CanuseMSBuild,whichinturnintegrateswithTFS/CIoptions
SQLHero
Precludesnoneoftheabove Precludes none of the above Addstouchtestingcapabilityduringdevelopmentcycle,transparently Sourcecontrolintegrationinterops withDatabaseProjects! Largedatasetsareencouragedandeasytobuild Compliancecheckingincorporatedthereactsagainstrealdatabases,can bescheduled,emaildelivery(advantages!) Supportsautomatedoperations
Example: DB reconcile from branched dev to branched QA (both stateful worked Example:DBreconcilefrombrancheddev tobranchedQA(bothstateful,worked prettyflawlesslywithasimple.cmd script)
Moreusecasestosupport:testingfromacollectedworkload
Yourenvironment
Dodevelopersdoactualdatamodeling? Dodeveloperswantasharedenvironment?
Offers
LookingforCustomerAdvisoryBoard members
Freeenterpriseeditioninexchangeforongoing feedback(iterativedevelopmentonv next feedback (iterative development on vnext features)
Nextreleasecomingsoon(alongwithnew g ( g whitepapers)
Stillfree! www.codexframework.com (Library) @sqlheroguy joelc@codexframework.com