版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、Parasoft C+test TrainingCathy FanSeptember 24, 2012cest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaAgendaPart 1Parasoft Test OverviewProject SetupTerminologyImportBDFStatic AnalysisTerminologyWorkflowTestingSuppressions ViolationsBest PracticesPart 2Automated Peer Code ReviewOverviewPre-commit vs.
2、Post-commitAuthors, Reviewers, ObserversWorkflowsAuditing the Code Review Processcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaAgendaPart 3Unit TestConcepts and StrategiesGenerating Unit TestsStubs and Project ScopeAssertionsCoveragePart 4Advanced Topics on Unit TestStubsFactory FunctionsParamete
3、rizationRuntime Error DetectionApplication MonitoringRuntime Error Detectioncest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaParasoft Test OverviewPurpose: Defect preventionTask management and distribution (Supports all aspects of project management)The primary question isDo you have the ability to
4、apply these technologies uniformly as part of a process and get results?NOT do you have access to these technologies?The key to effective usage is uniform application with minimal impact on the developers workflowParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaP
5、arasoft Test Functionality Overview Static analysis Automated peer code review (Language independent) Unit testing Runtime analysis Coverage analysis Task management and distribution (Supports all aspects of project management)cest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaParasoft Proprietary and
6、 Confidential1Create code and/or Unit Tests (auto or manual)3Execute nightly2Check into Source4Cross reference5Deliver results within IDEOverall Implementationcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaResults within IDE Show and TellParasoft Proprietary and Confidential1Results delivered as u
7、niform view within IDE2Directly access line of code to fix3Check-incest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaTogethernessSingle, uniform interfaceSame interface for all languagesSupport for all technologies needed in developmentWorkflow is naturalWork is task-based and focused on resultsTHE K
8、EY is uniform implementation in the groupIf implemented as a group practice, the result is huge productivity improvementsParasoft Proprietary and ConfidentialParasoft C+test Project Setupcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaTerminologyEclipse WorkspaceDirectory path that you had to speci
9、fy at startupContains a collection of projects Has a “.metadata/” folder and a “.cpptest” folderEclipse ProjectHas a “.project” filecest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaProject SetupC+test needs to knowCompilerBuild commandsBuild optionsFilesMethodsImport project from embedded IDE Use ex
10、isting build systemBuild data filecest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaImporting a Projectcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaWhat is a BDFBDF gives this information to C+testText deconstructed build options- cpptesttrace v.0 -working_dir=C:UserscfanATMproject_name=AT
11、Marg=C:cygwinbing+.exearg=-garg=-Iincludearg=-oarg=obj/ATM.oarg=-carg=ATM.cxxcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaGenerating a BDFPrerequisiteThe project is buildable on the machinecpptesttraceMonitors the build and puts all commands into the BDFThe project needs to be buildableOptions -
12、cpptesttraceProjectName-cpptesttraceOutputFileFor more options and explanationcpptesttrace -cpptesttraceHelpEx. cpptesttrace -cpptesttraceProjectName=ATM makecest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaImporting a ProjectThen test with Static Analysiscest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationt
13、emplaCustom Compilerscest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaTroubleshootingIf trying import from existing IDE results in project incorrectly being brought inDelete the project from the workspace and try againTry the BDF import methodThe BDF import is missing files from the project/is skipp
14、ing the Static Analysis testDouble-check the C+test project propertiesProject Properties Parasoft C+test Build SettingsDouble-check the BDF looks correctcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaC+test BasicsIts time for C+test BasicsChapter 1 Introduction to Parasoft C+test Chapter 2 Creatin
15、g Projects Lessons 1-3, 5Exercises 1-5Chapter 3 Team Workflow Read throughParasoft Proprietary and ConfidentialParasoft C+test Static Analysiscest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaWhat IS Static Analysis?Variety of methodsPeer Review / Manual Code Review / Code InspectionPattern-based cod
16、e scannersFlow-based code scannersMetrics code scannersCompiler / build outputBenefitsPrevent ProblemsTarget ProblemsLearningParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaStatic AnalysisPattern-BasedFlow-BasedMetricsDefectscest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresen
17、tationtemplaWhat is: Pattern-Based SAWhat:Identify specific patterns in the codeWhy:Find dangerous practicesPrevents defectsEnsure inclusion of required itemsSecurityBrandingParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaPattern-Based Static AnalysisQuick scan
18、to list possible problemsFixing violations prevents certain classes of errorsEach source analyzed separatelyStatic analysis categories include:Logical ErrorsAPI MisuseTypographical ErrorsSecurityThreads and SynchronizationPerformance and OptimizationParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊p
19、arasoftctesttraingpresentationtemplaWhat is: Data Flow AnalysisWhat:Simulate execution to find patternsWhy:Find real bugsParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaData Flow AnalysisSimulate hypothetical execution pathsDetect possible errors along those pat
20、hsData flow analysis error categories include:ExceptionsOptimizationResource LeaksAPI misuseSecurityParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaWhat is: Code MetricsWhat:Measurement of code based on various statisticsWhy:Understanding codePossible problemsPa
21、rasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaC+test Static AnalysisIts time for C+test Static Analysis Chapter 4 Static Code Analysis Lesson 1 - 9Exercise 1-6Parasoft Proprietary and ConfidentialParasoft C+test Static Analysis cont.cest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttrai
22、ngpresentationtemplaBeing SuccessfulChoose rules carefullyImplement progressivelyFewer to more rulesExtend date backwardSuppressions for exceptionsParasoft Proprietary and ConfidentialCode Review and Regression Testingcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaTips for ConfigurationDont get ov
23、erwhelmed!Same set of rules for everyoneSmall set of rules to have a valueFewer rules that are followed is better than more that are notIf you wouldnt fix it, dont check for itParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaConfiguration OptionsConfiguration aff
24、ects adoptionRules for new code vs legacy codeCut-off datesAvoid “we want to comply with this later”Parasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaTackling Static Analysis OutputAvoid the old “automated build and email” modelAssign to last person to touch the c
25、odeSend relevant tasks directly to developer UIParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaSample UIParasoft Proprietary and Confidential1Results delivered as uniform view within IDE2Directly access line of code to fix3Check-incest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraing
26、presentationtemplaStatic Analysis WorkflowSCMSource ControlcodeTeam ServerTest ResultsScheduled TestServerReport CenterCommand Line ExecutionTeam CodingStandardsDeveloperMachinesArchitect / Technical leadTestResultsProgram ManagerArchitectcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaEase of use
27、/ FeaturesDuplicate/child test configurationsModifying test configurationsPrintable rule docsFavorites (personal and team)DifferenceSeverity ChangeScopingReportsRecommended quality taskscest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaAddressing ViolationsUnderstanding code and violationSee rule doc
28、umentation for rule detailsMultiple methods:Fix the codeSuppress exception to the rulesvia Team Servervia Code CommentsPeer reviewShould you re-test from your desktop?If you have time, code, and setup, sureData Flow analysis is time consumingParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftc
29、testtraingpresentationtemplaTroubleshootingSkipping filesCheck the C+test project settingsCheck that the mentioned in the BDFCompilation or Parse errorsDoes the project build outside of C+test?Check the C+test project settings/compiler being usedx86 and x84_64Make sure C+test is run under the correc
30、t environmentValidate the compilation errorCreate a Technical Support Archive with the preprocessed send it to support for helpcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaC+test Static Analysis 2Its time for C+test Static AnalysisChapter 5 Static Analysis Workflow Lesson 1 7, 9 12Parasoft Propr
31、ietary and ConfidentialParasoft C+test TrainingCathy FanSept 25, 2012cest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaAgendaPart 1Parasoft Test OverviewProject SetupTerminologyImportBDFStatic AnalysisTerminologyWorkflowTestingSuppressions ViolationsBest PracticesPart 2Static Analysis ReviewAutomated
32、 Peer Code ReviewOverviewPre-commitPost-commitWorkflowsAuditing the Code Review Processcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaStatic Analysis ReviewQuestions?cest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaWhy do Code Review?Find defects earlyFind real functional problemsIncrease breadth
33、of understandingLeads to increased productivityParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaMethods of Code ReviewCode Review “in a room”Wastes timeDevelopers are inhibitedUsing an automated infrastructureconsistentParasoft Proprietary and Confidentialcest培培訓(xùn)
34、訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaDetermining ReviewersWho reviews whomHow close are they in the code?Increase code understandingParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaPutting it togetherTwo methods for code reviewPre-commitPost-commitThe next s
35、lides show how to do itPlanningSetting up tasksPerforming the workFirst phase of code review should be pre-commitParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaPre-Commit Code Review WorkflowParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpr
36、esentationtemplaWhen to use pre-commitShouldnt be for normal experienced developersException: when first starting the Code Review processSetup policies to determine when to useNew developersNew team membersSignificant code changesMore than 2-3 files for a single fixParasoft Proprietary and Confident
37、ialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaWhen is it enough?When everyone agreesPre-commit will hold up other development effortsBalance between full review and getting things doneParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaSetting Up Code Review f
38、rom the UIPreferencesConcertoTeam ServerCode ReviewScope and AuthorshipSource ControlTest ConfigurationScopeCode ReviewCommoncest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaPost-commit code reviewWho reviews whom is keyGuarantees that 100% of modified code is reviewed For experienced developersUse
39、for smaller changesParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaCode Review HistoryConcerto stores everythingGreat for accountabilityWhat you sayParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaReview ClassificationsParaso
40、ft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaReading the Review GraphParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaReview Task ClassificationNew issues by severityReviewer classifiesNew issues by categoryParasoft Proprietary
41、and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaReviewers TasksParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaWhat shouldnt you look atCode formation use static analysisBeautificationNaming conventions Some are related to functionality check th
42、osePattern based should be checked in SAParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaWhat should you look at?Metrics violationsThings not covered by static analysisFunctionalityExtend understanding of the codeParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊p
43、arasoftctesttraingpresentationtemplaThings to look forMake sure source control comments are meaningfultask ID is in the review comments so you know what the change is related toTry to understand what theyre trying to doWhat is the logicHow does it fit the overall systemHow “clean” is the codeProper
44、design patterns MOST IMPORTANTDoes each class do one thingDoes each method do one thingAre methods named according to what they do?Naming should fitParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaMore to look forRefactoringWhat is the general impact of the chang
45、e being made?Do you know other areas the change will affect?Design patterns used are they appropriate?Other policiesParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaReviewing code formattingNormally trust the SA tool to do thisNew developers doing pre-commit get
46、extra scrutinyLegacy code is a challengeContested policies are a challengeThey dont belong in early adoption, or even later.As people used to doing SA and CodeReview it becomes easier to introduce such changes.Parasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaSett
47、ing HealthCheck PolicyParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaThe FutureParasoft C+test TrainingCathy FanSept 26, 2012cest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaAgendaPart 3Unit TestConcepts and StrategiesGenerating Unit TestsStubs and Project Scop
48、eAssertionsCoveragePart 4Advanced Topics on Unit TestStubsFactory FunctionsParameterizationRuntime Error DetectionApplication MonitoringRuntime Error Detectioncest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaCode Review QuestionsQuestions?cest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaWhat IS Unit
49、 Testing?Testing Units of Code Functional Testing Acceptance Testing System Testing Regression TestingCPPUnit extension“Code that exercises a small well-defined area of functionality to prove that it works as intended”Parasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationte
50、mplaWhy Unit Test?Regression TestingFinds unwanted changes earlierHelps validate designProduces better softwareDocuments current behaviorEasier to debug laterTest-Driven DevelopmentConfirms functionalityBecomes regression testsTime saved writing testsParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊
51、parasoftctesttraingpresentationtemplaKeep in mindUnit tests require a LOT of careUnit testing is a continuous operationTest suite maintenance is a commitmentNo silver bulletParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaAnatomy of a Unit TestLike Black-box test
52、ingSetupInput and global variablesMock functions (stubs), mock objects (factory functions), data sources, Call unitUsing the setupAssertionsValidate the outcome Expected vs. Actualcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaC+test Unit Test exampleAccount* getAccount(int num, string password);v
53、oid TestSuite_Bank_cxx_6ec01b54:test_getAccount_1()/ Setup function Inputs:Bank _cpptest_TestObject ;int _num = 0;:std:string _password = ;/ Calling the function:Account * _return = _cpptest_TestObject.getAccount(_num, _password);/ Assert valuesCPPTEST_ASSERT_EQUAL(0, ( _return );Parasoft Proprietar
54、y and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaAssertions - What to assertEase of creating assertions leads to poor choicesAnything CAN be checked but should it be?Assertions should be connected to what youre trying to testAssertions should be time invariantCheck values by range,
55、 not equivalence“What do I expect here logically?”Bad Assertions How often do you WANT to manually verify an assertion? Daily or near-daily checking indicates poor assertion.Parasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaAssertions - Why assertions failIntroduc
56、ed coding errorFix the new codeFunctionality changedUpdate the assertionImproper assertionComment it out with a reason / TODOParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaUnit Test CreationAuto-GeneratedGood for freezing codeExposes exceptionsEasy to abuseAppl
57、y in targeted mannerBuilt-in Configuration: test optionsReplacing old unit testsTest cases per functionPrivate, protected, publicWizard-GeneratedSpecific scenarioHuman effortReview the tests as you work on the codeIts all the same to C+testcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaInput Excep
58、tionsReview and handleFix codeDrop assertionSkip testParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaRun Unit Tests - ResultsBuilt-in configurations: optionsScopingResultsQuality TasksPost ConditionsAssertion FailuresExceptionscest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpres
59、entationtemplaCoverageCoverageLineLine hit countDecisionPathSimple ConditionBlockStatementMC/DCcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentationtemplaC+test Unit TestIts time for C+test Unit Test Chapter 6Lesson 1 8 Exercise 1 6 Parasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手冊parasoftctesttraingpresentat
60、iontemplaWhere do tests live?Always under source controlSeparate auto-generation from hand-codedPossible locationsSame dir as class being testedSame structure, different dir, in the same projectSame structure, but separate testing projectTeam agreementParasoft Proprietary and Confidentialcest培培訓(xùn)訓(xùn)手冊手
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 七年級上冊課件英語
- 教案-金屬及其化合物,預(yù)習(xí)
- win7操作系統(tǒng)課件
- 建筑色彩教案
- 玉溪師范學(xué)院《素描人像》2022-2023學(xué)年第一學(xué)期期末試卷
- 我愛刷牙課件小班
- 別丟掉林徽因課件
- 2024年電力保護(hù)設(shè)備項(xiàng)目綜合評估報(bào)告
- 2024年硬幣清分機(jī)項(xiàng)目評估分析報(bào)告
- 2023年新型聚合物驅(qū)油劑項(xiàng)目綜合評估報(bào)告
- 生產(chǎn)部管理人員考試題(新進(jìn)轉(zhuǎn)正)范本
- 高中研究性學(xué)習(xí)如何選擇、確立研究性學(xué)習(xí)課題PPT通用PPT課件
- 6S管理知識圖解
- 高速鐵路ZPW-2000軌道電路
- 縣國家稅務(wù)局文件材料歸檔范圍及文書檔案保管期限表
- 兒童消化道出血診療(課堂PPT)
- 橋梁荷載試驗(yàn)講座
- 醫(yī)師定期考核表格參考模板
- 英語人教版三年級上冊(教具)動(dòng)物圖卡
- 泥水平衡頂管施工方案
- 民辦非企業(yè)單位(法人)登記申請表08669
評論
0/150
提交評論