DOC PREVIEW
UMD CMSC 132 - Object-Oriented Programming II

This preview shows page 1-2-3-26-27-28 out of 28 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 28 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 28 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 28 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 28 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 28 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 28 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 28 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1CMSC 132: Object-Oriented Programming IINelson Padua-PerezWilliam PughDepartment of Computer ScienceUniversity of Maryland, College Park2OverviewTestingUnified Modeling Language (UML)Models & viewsClass diagramsSequence diagrams3TestingGoalDetect and eliminate errors in programFeedback to improve softwareSpecification changesAdd new functionalityExtremely important for success!4TestingEmpirical testingTest software with selected test casesMore scalable than verificationNot guaranteed to detect all errors5Testing – TerminologyTest caseIndividual testTest suiteCollection of test casesTest harnessProgram that executes a series of test casesTest frameworkSoftware that facilitates writing & running testsExample – JUnit6Testing – TerminologyTest driverProgram to create environment for running testsDeclares variables, creates objects, assigns valuesExecutes code and displays results of testsStubSkeleton code in place of unfinished method / classSimply return if calledPossibly print message indicating stub calledAllows software testing to begin7Testing – TerminologyTester (Quality Assurance)Person devising and / or performing testsMore effective if 2nd person writes testsWalkthroughProgrammer explains code to 2ndperson8Types of TestingClear box testingAllowed to examine codeAttempt to improve thoroughness of testsBlack box testingNo knowledge of codeTreat program as “black box”Test behavior in response to inputs9Levels (Stages) of Testing1.Unit test2.Integration test3.System test4.Acceptance test10Unit TestTest individual units extensivelyClassesMethodsCentral part of “eXtreme Programming” (XP)Extensive unit testing during developmentPair programming (1 coder, 1 tester)Design unit tests along with specificationApproachTest each method of classTest every possible flow path through method11Flow PathUnique execution sequence through programExample S1while (B1) {if (B2)S2elseS3}FlowsS1S1, S2S1, S3S1, S2, S2S1, S2, S3S1, S3, S2S1, S3, S3…12Unit Test – Flow PathNot possible to test all flow pathsMany paths by combining conditionals, switchesInfinite number of paths for loopsNew paths caused by exceptionsTest coverageAlternative to flow pathEnsure high % (if not all) of lines of code testedDoes not capture all possible flow pathsEven if all lines of code tested by some test case13Integration TestTest interaction between unitsPossible units fail when combinedMay find problems in specificationsApproachTest units togetherProceed bottom up, in increasing sizeExample test sequence1.AB, AC, AD, CD, CE2.ACD3.ABCDEBACDE14System TestTest entire softwareInclude all components of softwareIn context in which software will be usedEnsure all pieces of software interact correctly15Acceptance TestTest full functionality of softwareEnsure program meets all requirementsApproachPlace software in user environmentTest software withReal-world dataReal usersTypical operating conditionsTest cases selected by users16Acceptance Test – StagesAlpha testTest components during developmentUsually clear box testBeta testTest in real user environmentAlways black box test17Regression TestEnsure functionality is not lost / changedAs software is modified / extendedApproachSave suite of tests and expected resultsRerun test suite periodically after software changesReport any loss of functionalityTypically run overnight Software is more stable when developers leave work18Developing Test CasesQuality of testing depends on test casesTips on developing test casesDevelop test data during analysis & design phasesAttempt to exercise alternate program pathsCheck boundary conditions 1stand last iterations of loop1stand last values added to data structurePay close attention to problem specificationUML use cases →→→→ test cases19UMLUML (Unified Modeling Language)Graphic modeling language for describing object-oriented softwareStarted in 1994Combined notations from 3 leading OO methodsOMT (James Rumbaugh)OOSE (Ivar Jacobson)Booch (Grady Booch)Industry standard Many featuresLarge collection of notationsMultiple viewsMultiple diagramsWe focus mainly onLogical view of relationship between classes20UML MotivationSoftware growing larger & complexDifficult to analyzeNeed to describe software designClearlyConciselyCorrectlyUML equivalent to software “blueprint”Provides simple yet clear abstraction for softwareComputer-aided software engineering (CASE)Tools for generating & analyzing UML21(Some) UML DiagramsClassDescribe static structure of the classes in system SequenceDescribe dynamic behavior between users and objects Use caseDescribe functional behavior seen by (external) userStateDescribe dynamic behavior of objects as finite state machineActivityModel dynamic behavior of a system as a flowchart22Sequence DiagramObjectMessageActivationSequence diagrams represent behavior as interactionsblinkHours()blinkMinutes()incrementMinutes()refresh()commitNewTime()stopBlinking()pressButton1()pressButton2()pressButtons1And2()pressButton1():WatchUser:Time:LCDDisplay:SimpleWatch23Use Case DiagramsWatchUser WatchRepairPersonReadTimeSetTimeChangeBatteryActorUse casePackageSimpleWatchUse case diagrams represent functionality of system from external user’s point of view24button1&2Pressedbutton1&2Pressedbutton1Pressedbutton2Pressedbutton2Pressedbutton2Pressedbutton1Pressedbutton1&2PressedIncrementMinutesIncrementHoursBlinkHoursBlinkSecondsBlinkMinutesIncrementSecondsStopBlinkingState DiagramsStateInitial stateFinal stateTransitionEvent25UML Class DiagramsRepresent the (static) structure of the systemDuring analysis Used to model problem domain conceptsDuring detailed design Used to model classes26Class DiagramsClass containsNameStateBehaviorVisibility Specifiers+ public - private# protected~ package27UML Class Diagrams ↔↔↔↔ Java CodeDifferent representation of same informationName, state, behavior of classRelationship(s) between classesShould be able to derive one from the other MotivationUML ⇒⇒⇒⇒JavaImplement code based on design written in UMLJava ⇒⇒⇒⇒UMLCreate UML to document design of existing code28Java →→→→ UML : Clock ExampleJavaclass Clock { // name// stateprivate int seconds;private int minutes;private int hours;// behaviorpublic void start();public void adjustTime(int value);public void reset();}Java CodeClass


View Full Document

UMD CMSC 132 - Object-Oriented Programming II

Documents in this Course
Notes

Notes

8 pages

Recursion

Recursion

12 pages

Sorting

Sorting

31 pages

HTML

HTML

7 pages

Trees

Trees

19 pages

HTML

HTML

18 pages

Trees

Trees

19 pages

Honors

Honors

19 pages

Lecture 1

Lecture 1

11 pages

Quiz #3

Quiz #3

2 pages

Hashing

Hashing

21 pages

Load more
Download Object-Oriented Programming II
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 Object-Oriented Programming II 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 Object-Oriented Programming II 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?