DOC PREVIEW
Purdue ECE 462 - Lecture notes

This preview shows page 1-2-3-4-28-29-30-31-57-58-59-60 out of 60 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 60 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

TestingTesting StrategyDesign and TestingTest CoverageExecution PathQuantify Testing QualityTesting StepsUnit TestingTop-Down IntegrationBottom-Up IntegrationTest DocumentationHypothesis-Test DebuggingTime-Sensitive or Massive DataLayered StructureWhy to Layer Files / ClassesTest Exceptional CasesAutomatic TestingPeriodic Tasks using cronCron TasksCrontabg++ -fprofile-arcs -ftest-coverage3-Dimensional GraphicsForeshortening3D Graphics in C++ and JavaShow 3D on 2D ScreenCalculate Projection on ScreenProjectionsWhy is 3D More ComplexGeometric Representations3D TransformationTransformation not CommutativeECE 462Object-Oriented Programmingjggusing C++ and JavaTestingYung-Hsiang Lul@ d [email protected] Testing 1Unreachable CodeUnreachable CodeIf a, b, and c are zeros or positive numbers,, p(a + c) < b ⇒ a > b is impossible⇒ problem in the logic?if ((x <= 0) && (x >= width)) // hit left or right wall{//{// width > 0vx = -vx; // change direction}}YHL Testing 2Testing StrategyTesting Strategy•Testing is one, not the only one, step to ensure quality.g, y,p qy• Before writing code, think about how to test it.• Do not be surprised that you write more code for testing than for the project.• Danger of using testing to ensure quality: you usually test what you suspect The program usually breaks attest what you suspect. The program usually breaks at places where you are confident.• Sometimes, reading code line-by-line can find and fix problems faster than writing testing code, especially for multi-thread programs.YHL Testing 3Design and TestingDesign and Testingcode unit testfamiliar to most of youdesign integration testrequirementsvalidation testrequirementsvalidation testsystem engineering system testingoften the hardest• Importance of unit testing: well-designed software should allow only limited visibility(encapsulation) for better yy(p )consistency. Hence, testing from outside is difficult.• Build software in layers. A lower layer should be fully tested before building a higher layerYHL Testing 4tested before building a higher layer.Test CoverageTest Coverage• How much code is exercised in a test? How many ypossible paths are traversed?• Many tools exist for reporting code coverage.• Low coverage: not fully tested ⇒ bad test• High coverage: can hardly test each possible path⇒qualityunclear⇒quality unclear• Testing discover many problems? good or bad?•"dead code": code that is impossible to reach usuallydead code : code that is impossible to reach, usually indicates design or coding errorsreturn 0;++YHL Testing 5x ++;}Execution PathC1Execution PathC1C1C4C3C2C1C4C3C6C2C4C3C6C5C2C4C3C2C6C7C5C7C6C7C5C: code segmentC7Every node has been visited(100% test coverage) butC2C6 h t b t t dC2YHL Testing 6C: code segmentC2→C6 has not been testedC6Quantify Testing QualityQuantify Testing Quality• coverage: (% code and % paths) of the testg( p )• efficiency: evenly distribute? time to cover 99%?• progression: % new code tested • discovery rate: % bugs found for every line of test code• configurability: selections of features to test• ratio: how much testing code needed to test actual code• expandability: amount of efforts needed to test new featuresfeatures• degree of automation: can it be fully automated, semi-automated, or complete manual?YHL Testing 7Testing StepsTesting Steps• unit testing, integration testing, regressiong, g g, g• unit testing:– individual components– often conducted by the developer– often using dedicated testing code to create input data exercise the componentsdata, exercise the components– often traced by single steps–check boundary conditions and error handlingcheck boundary conditions and error handling– check interface correctness and responses to incorrect inputsYHL Testing 8Unit TestingUnit Testing–examine the performancep– should be performed before "cvs commit"– should be put into the repository– should be configurable for related components– require careful planning in advance–driver: code to call the component, stub: code to be called by the component. both are overheadstubstubdrivertest case 1test case 2tt 3componentstubstubstubstubYHL Testing 9test case 3test case 4stubstubIntegration TestingIntegration Testing• Interface incompatibility is often the reason software breaks. incompatibility ≠ compiler error• types of interface errors, even passing compilation, e.g.–wrong types (object of derived class or base class)gyp ( j )– wrong assumptions, for example• who is responsible for allocating or releasing memory•who may modify the data especially global variables•who may modify the data, especially global variables• sorted or nearly sorted? wrong result or wasting time– wrong timing assumption for real-time software• incremental integration: add one component (e.g. class) each time• may still use drivers and stubs (how do you know they are correct?)YHL Testing 10Top-Down IntegrationTopDown Integration• using control flow to determine the integration ordergg• starting from the main component ("main" in C/C++) as the driver• integrate callees (replace stubs) of the main component• depth-first integration: C1, C2, C5, C7breadthfirst integration: C1 C2 C3 C4C1: main•breadth-first integration: C1, C2, C3, C4• after one successful test, replaceastubby the realcomponentC4C3C2a stubby the real component• regression test (later) toensure tested componentsC6C5C2YHL Testing 11pstill workC7Challenges in Top-Down TestingChallenges in TopDown Testing• control flow and call graph are not gpdownward only or acyclic• many functionalities cannot be tested b f th l f t b iltC1before the leaf components are built, e.g. C1 needs the data (or objects) generated in C7C4C3C2objects) generated in C7 to test C3•depth-first or breath-first onlyC6C5pymay not represent normalexecution pathsC7YHL Testing 12Bottom-Up IntegrationBottomUp Integration1. start from individual components (such as classes)p( )2. put several components together, use a driver to test them3. replace the driver by a real component4. repeat step 2-3difficulties:•difficulties:– which components to integrate first? They must have a common driver.– control may not be upward only or acyclic– required data (or objects) may be generated from a YHL Testing 13component that has not been integratedRegression TestingRegression Testing• re-test what has been tested after new components are


View Full Document

Purdue ECE 462 - Lecture notes

Download Lecture notes
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture notes 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?