+ All Categories
Home > Documents > Microsoft SQL Server Unit Testing - July 2011

Microsoft SQL Server Unit Testing - July 2011

Date post: 07-Apr-2018
Category:
Upload: mark-ginnebaugh
View: 215 times
Download: 0 times
Share this document with a friend

of 23

Transcript
  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    1/23

    SQLServerUnitTestingSQLServerUnitTesting

    JoelChampagne,

    July2011MarkGinnebaugh,UserGroupLeader,

    .

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    2/23

    20yearsconsultingexperience

    argem ss oncr t ca systems

    .NET,

    SQL

    2000

    2008,

    SSAS,

    SSRS,

    SSIS Architecture,DataArchitecture

    Focusondeveloperproductivitytools

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    3/23

    UnitTesting whatsaunit?

    n es ng asprovenva ua e nmanylanguages

    thosebreakagesearly

    SomemaysaySQLhasgottentheshortendoft estic ere orvariousreasons Harder: time/efforttowritetestsforpossibly

    thousandsofob ects man ofwhichcouldbeCRUD

    Separationofdevelopmentprocess

    Statefulness: dependenceonspecificdatatomakeit

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    4/23

    Supposetheresanexistingprocedurewhich

    has

    been

    working

    for

    ages

    updatingthisprocedureforwhateverreason

    e. . different database

    Failsatruntime youwouldhaveknown,

    ,

    Also,whatdoesSSMStelluswhenwecommit

    e ro enproce ure

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    5/23

    Scheduled

    Strategic

    Build

    /

    moving

    objects Automation

    Includesonchange

    ContinuousIntegrationstrategies

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    6/23

    Setuptests,perobject

    Can ave expecte resu ts

    SchemaViewofferseasywaytoscript,per

    object

    Demo

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    7/23

    Observations Quitepowerfulaswecancraftdatadriven

    NotnecessarilytestingSQLdirectly(canbe.NETcom onents

    Nextslideexample

    Hoststestsinrunnablecode S Lscri tsthemselvesstoredinresourcefile)

    Inte ratesas artofalar ertestin infrastructureavailablewithVisualStudio

    Testrigs,agents,etc.

    Canmakeascomplexasdesired

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    8/23

    Data

    driven

    example

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    9/23

    SQLHero Problemstryingtoaddress:

    Developersoftendontliketoinvesttimeinwritingtests

    Wanttoexercisetestsearlyandoften! OnALTERandscheduled(andondemand)

    Leveragetestswe o aveatstrateg ct mes: e.g.scr pt ngchangestoanewplace

    Canincludetheseautomaticallyfromtheschemacomparetool!

    Settingoftargets,notjustthresholds(sowecandoreporting/analysisvs.targets)

    strictlytietoasingledatabase)

    Realityofdatabaseswithhundredsoftables,reference, .

    fromscripts,etc.

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    10/23

    Confi uration

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    11/23

    TestingPolicies.xmlExample: aproc parameterthatendsinAreaID,populateusingaselectfromAreatablethatisfiltered

    AreaID$

    SELECTAreaID FROMAreaaWHEREa.AreaAbbr LIKE'A%'

    Example: aproc parameterof@DocTypeID thatrelatestoatablecalledCommDocumentType

    @DocTypeID

    CommDocumentType

    Example: asampleplugin,putintheprogramfiles\sqlhero\pluginsdirectory

    SampleTestingPlugIn.dll

    SampleTestingPlugIn.MyTestPolicy

    < >

    Example: allobjectsintheDebugschemawouldbeexcludedfromtesting

    ^\[?Debug\]?\.

    True

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    12/23

    capturedworkloadstoseeifanalready

    Isusingarandomizedprocess,butinfluenced

    Nosideeffects

    Rollbackperobject Advantages/Disadvantages

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    13/23

    Creatin

    Tests

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    14/23

    ViaTemplate

    ViaTemp ate,wit para e execution

    From

    SHCommand.exe From.sqlheroproj VisualStudioprojecttype

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    15/23

    Some

    Observations Presenceoftouchtestinghasprovenvaluefrom

    SQLHerotestingcanaugmentVStesting: VSforformalunittestswhicharepartofbuild

    process,complexcaseswherecanuseC#

    SHfortouchteststhatarejusttherebehindthescenestofindcertainissuesfor outrans arentl

    OutputofSHtestingtemplatecanbeusedinVS,ifyoulike!

    consideringsomenewfeaturesalongthelinesofturningcapturedworkloadsintocomplextestcases(C#)

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    16/23

    Some

    Observations Presenceoftouchtestinghasprovenvaluefrom

    SQLHerotestingcanaugmentVStesting: VSforformalunittestswhicharepartofbuild

    process,complexcaseswherecanuseC#

    SHfortouchteststhatarejusttherebehindthescenestofindcertainissuesfor outrans arentl

    OutputofSHtestingtemplatecanbeusedinVS,ifyoulike!

    consideringsomenewfeaturesalongthelinesofturningcapturedworkloadsintocomplextestcases(C#)

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    17/23

    A

    more

    com lex

    use

    case Problemstryingtoaddress:

    Dataqualityindevelopmentregions

    Securityandisolationofproductiondata

    Inprogresswork(usingexternalsourcecontrol?)

    Howdoesunittestingrelate?

    Integrated

    as

    part

    of

    the

    process

    to

    ensure

    things

    still

    w u

    Overallprocesscanserveasonewaytoachievethecovetedknownstartingpoint easily

    YMMV

    may

    e

    simp er

    or

    more

    comp ex

    i e y

    supported!)

    Watchforawhite a erdescribin thisin reatdetail

    Demo

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    18/23

    Amorecomplexusecase illustrated

    Prod

    (remote) QAQANewBackup

    Backup/

    Restore

    QANew(remote)

    Remove

    Scramble

    sensitive

    data

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    19/23

    Amorecomplexusecase illustrated

    Detach Move

    Prod

    (remote) QAQANewBackup

    Files,Attach

    Sync

    Pending

    Changes

    QANew

    Backup

    Restore

    FTPLanding

    Zone

    QANew

    Performtests

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    20/23

    Amorecomplexusecase illustrated

    Prod

    (remote) QAOld

    Email

    relevant

    arties about

    QA

    completion

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    21/23

    Puttingittogether

    Build >Deploy(localorshared)

    Canexercisestaticcodeanalysis

    Can

    use

    MSBuild,

    which

    in

    turn

    integrates

    with

    TFS

    /

    CI

    options SQLHero

    Addstouchtestingcapabilityduringdevelopmentcycle,transparently

    Sourcecontrolintegrationinterops withDatabaseProjects!

    Largedatasetsareencouragedandeasytobuild Compliancecheckingincorporatedthereactsagainstrealdatabases,can

    bescheduled,emaildelivery(advantages!)

    Supportsautomatedoperations ,

    prettyflawlesslywithasimple.cmd script)

    Moreusecasestosupport: testingfromacollectedworkload

    Yourenvironment Dodevelopersdoactualdatamodeling?

    Do

    developers

    want

    a

    shared

    environment?

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    22/23

    LookingforCustomerAdvisoryBoard

    Freeenterpriseeditioninexchangeforongoing

    features)

    Nextreleasecomin soon alon withnewwhitepapers)

    Stillfree!

    www.codexframework.com (Library) @sqlheroguy

    [email protected]

  • 8/6/2019 Microsoft SQL Server Unit Testing - July 2011

    23/23

    Tolearnmoreorin uireabouts eakin o ortunities leasecontact:MarkGinnebaugh,UserGroupLeader

    [email protected]


Recommended