UML Diagrams and Software Testing Instructor: Scott Kristjanson CMPT 135 SFU Surrey, Spring 2016.

Slides:



Advertisements
Similar presentations
Object Oriented Analysis And Design-IT0207 iiI Semester
Advertisements

Software Testing. Quality is Hard to Pin Down Concise, clear definition is elusive Not easily quantifiable Many things to many people You'll know it when.
Unit Testing in the OO Context(Chapter 19-Roger P)
Lecture 8: Testing, Verification and Validation
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
10 Software Engineering Foundations of Computer Science ã Cengage Learning.
Inheritance Inheritance Reserved word protected Reserved word super
CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
Object-Oriented Analysis and Design
Lecturer: Sebastian Coope Ashton Building, Room G.18 COMP 201 web-page: Lecture.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter Software Development Software Life Cycle UML Diagrams.
Chapter 1 Software Development. Copyright © 2005 Pearson Addison-Wesley. All rights reserved. 1-2 Chapter Objectives Discuss the goals of software development.
Exam Review 2 Chapter 5 – 9 CS211 November 05,2007, CS Dept, MHC.
ECE122 L16: Class Relationships April 3, 2007 ECE 122 Engineering Problem Solving with Java Lecture 16 Class Relationships.
IMSE Week 18 White Box or Structural Testing Reading:Sommerville (4th edition) ch 22 orPressman (4th edition) ch 16.
16/27/2015 3:38 AM6/27/2015 3:38 AM6/27/2015 3:38 AMTesting and Debugging Testing The process of verifying the software performs to the specifications.
Chapter 1 Principles of Programming and Software Engineering.
Testing an individual module
Software Engineering Principles and C++ Classes
Chapter 18 Testing Conventional Applications
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
ECE122 L17: Method Development and Testing April 5, 2007 ECE 122 Engineering Problem Solving with Java Lecture 17 Method Development and Testing.
C++ fundamentals.
BY RAJESWARI S SOFTWARE TESTING. INTRODUCTION Software testing is the process of testing the software product. Effective software testing will contribute.
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
Testing. Definition From the dictionary- the means by which the presence, quality, or genuineness of anything is determined; a means of trial. For software.
TESTING.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
Writing Classes (Chapter 4)
Objectives Understand the basic concepts and definitions relating to testing, like error, fault, failure, test case, test suite, test harness. Explore.
Programming in Java Unit 3. Learning outcome:  LO2:Be able to design Java solutions  LO3:Be able to implement Java solutions Assessment criteria: 
Dr. Tom WayCSC Testing and Test-Driven Development CSC 4700 Software Engineering Based on Sommerville slides.
Chapter 10: Software Engineering
Software Construction Lecture 18 Software Testing.
Data Structures Using C++1 Chapter 1 Software Engineering Principles and C++ Classes.
1 Object Oriented Design and UML Class Relationships –Dependency –Aggregation –Interfaces –Inheritance Interfaces Reading for this Lecture: L&L 6.4 – 6.5.
Static class members.
1 Ch. 1: Software Development (Read) 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution.
1-1 Software Development Objectives: Discuss the goals of software development Identify various aspects of software quality Examine two development life.
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
Data Structures Using C++ 2E
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Software Engineering 2004 Jyrki Nummenmaa 1 BACKGROUND There is no way to generally test programs exhaustively (that is, going through all execution.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
Software Engineering and Object-Oriented Design Topics: Solutions Modules Key Programming Issues Development Methods Object-Oriented Principles.
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
Reviewing for the Midterm Covers chapters 1 to 5, 7 to 9 Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 11 Object-Oriented.
Software Engineering Saeed Akhtar The University of Lahore.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Object-Oriented Design.
SOFTWARE TESTING. Introduction Software Testing is the process of executing a program or system with the intent of finding errors. It involves any activity.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
Verification vs. Validation Verification: "Are we building the product right?" The software should conform to its specification.The software should conform.
Testing Integral part of the software development process.
© 2004 Pearson Addison-Wesley. All rights reserved November 2, 2007 Class Relationships ComS 207: Programming I (in Java) Iowa State University, FALL 2007.
Principles of Programming & Software Engineering
Software Testing.
Software Testing.
Testing and Debugging PPT By :Dr. R. Mall.
Chapter 11 Object-Oriented Design
Principles of Programming and Software Engineering
About the Presentations
Testing and Test-Driven Development CSC 4700 Software Engineering
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Software Development Chapter 1.
Chapter 10: Software Engineering
Presentation transcript:

UML Diagrams and Software Testing Instructor: Scott Kristjanson CMPT 135 SFU Surrey, Spring 2016

Slides based on Problem Solving with C++, 9th Edition, Walter Savitch 2 Scott Kristjanson – CMPT 135 – SFU Wk04.3 Slide 2 Encapsulation An encapsulated object can be thought of as a black box – its inner workings are hidden from the client The client invokes the interface methods of the object, which manages the instance data

Slides based on Problem Solving with C++, 9th Edition, Walter Savitch 3 Scott Kristjanson – CMPT 135 – SFU Wk04.3 Slide 3 Visibility Modifiers

Slides based on Problem Solving with C++, 9th Edition, Walter Savitch 4 Scott Kristjanson – CMPT 135 – SFU Wk04.3 Slide 4 Method Declarations A method declaration specifies the code that will be executed when the method is invoked (called) When a method is invoked, the flow of control jumps to the method and executes its code When complete, the flow returns to the place where the method was called and continues The invocation may or may not return a value, depending on how the method is defined

Slides based on Problem Solving with C++, 9th Edition, Walter Savitch 5 Scott Kristjanson – CMPT 135 – SFU Wk04.3 Slide 5 Methods The flow of control through methods:

Slides based on Problem Solving with C++, 9th Edition, Walter Savitch 6 Scott Kristjanson – CMPT 135 – SFU Wk04.3 Slide 6 Pass by Value Parameters When a method is called, the actual parameters in the invocation are copied into the formal parameters in the method header

Slides based on Problem Solving with C++, 9th Edition, Walter Savitch 7 Scott Kristjanson – CMPT 135 – SFU Wk04.3 Slide 7 Class Relationships Classes in a software system can have various types of relationships: Three of the most common relationships: Dependency: A uses B Aggregation: A has-a B Inheritance : A is-a B

Slides based on Problem Solving with C++, 9th Edition, Walter Savitch 8 Scott Kristjanson – CMPT 135 – SFU Wk04.3 Slide 8 UML Diagrams UML stands for the Unified Modeling Language UML diagrams show relationships among classes and objects A UML class diagram consists of one or more classes, each with sections for the class name, attributes (data), and operations (methods) Lines between classes represent associations A solid arrow shows that one class uses the other (calls its methods)

Slides based on Problem Solving with C++, 9th Edition, Walter Savitch 9 Scott Kristjanson – CMPT 135 – SFU Wk04.3 Slide 9 Dependency (A uses B) A dependency exists when one class relies on another in some way, usually by invoking the methods of the other We don't want numerous or complex dependencies among classes Nor do we want complex classes that don't depend on others A good design strikes the right balance

Slides based on Problem Solving with C++, 9th Edition, Walter Savitch 10 Scott Kristjanson – CMPT 135 – SFU Wk04.3 Slide 10 Aggregation (A has-a B) An aggregate is an object that is made up of other objects Therefore aggregation is a has-a relationship A car has a chassis The aggregate object is defined in part by the objects that make it up This is a special kind of dependency – the aggregate relies on the objects that compose it

Slides based on Problem Solving with C++, 9th Edition, Walter Savitch 11 Scott Kristjanson – CMPT 135 – SFU Wk04.3 Slide 11 Inheritance (A is-a B) Derived class IS-A more specific version of its Base Class Inheritance is indicated by a solid line with a closed, unfilled arrowhead pointing at the super class

Slides based on Problem Solving with C++, 9th Edition, Walter Savitch 12 Scott Kristjanson – CMPT 135 – SFU Wk04.3 Slide 12 Software Testing - Design and Code Reviews Review – meeting of several people designed to examine a design document or section of code Presenting a design or code causes us to think carefully about our work and allows others to provide suggestions Goal of a review is to identify problems Design review should determine if the system requirements are satisfied

Slides based on Problem Solving with C++, 9th Edition, Walter Savitch 13 Scott Kristjanson – CMPT 135 – SFU Wk04.3 Slide 13 Defect Testing Testing is also referred to as defect testing Though we don’t want to have errors, they most certainly exist A test case is a set of inputs, user actions, or initial conditions, and the expected output It is not normally feasible to create test cases for all possible inputs It is also not normally necessary to test every single situation

Slides based on Problem Solving with C++, 9th Edition, Walter Savitch 14 Scott Kristjanson – CMPT 135 – SFU Wk04.3 Slide 14 Defect Testing Two approaches to defect testing black-box: treats the thing being tested as a black box Test cases are developed without regard to the internal workings Input data often selected by defining equivalence categories – collection of inputs that are expected to produce similar outputs Example: input to a method that computes the square root can be divided into two categories: negative and non-negative

Slides based on Problem Solving with C++, 9th Edition, Walter Savitch 15 Scott Kristjanson – CMPT 135 – SFU Wk04.3 Slide 15 Defect Testing Two approaches to defect testing white-box: exercises the internal structure and implementation of a method. Test cases are based on the logic of the code under test. Goal is to ensure that every path through a program is executed at least once Statement coverage testing – test that maps the possible paths through the code and ensures that the test case causes every path to be executed

Slides based on Problem Solving with C++, 9th Edition, Walter Savitch 16 Scott Kristjanson – CMPT 135 – SFU Wk04.3 Slide 16 Other Testing Types Unit Testing – creates a test case for each module of code that been authored. The goal is to ensure correctness of individual methods Integration Testing – modules that were individually tested are now tested as a collection. This form of testing looks at the larger picture and determines if bugs are present when modules are brought together System Testing – seeks to test the entire software system and how it adheres to the requirements (also known as alpha or beta tests) Regression Testing – seeks to verify that recent changes have not broken existing functionality. Typically a small subset of test cases designed to cover key areas of functionality.

Slides based on Problem Solving with C++, 9th Edition, Walter Savitch 17 Scott Kristjanson – CMPT 135 – SFU Wk04.3 Slide 17 Test Driven Development Developers should write test cases as they develop their source code Some developers have adopted a style known as test driven development test cases are written first only enough source code is implemented such that the test case will pass

Slides based on Problem Solving with C++, 9th Edition, Walter Savitch 18 Scott Kristjanson – CMPT 135 – SFU Wk04.3 Slide 18 Test Driven Development Test Driven Development Sequence 1.Create a test case that tests a specific method that has yet to be completed 2.Execute all of the tests cases present and verify that all test cases will pass except for the most recently implemented test case 3.Develop the method that the test case targets so that the test case will pass without errors 4.Re-execute all of the test cases and verify that every test case passes, including the most recently created test case 5.Clean up the code to eliminate redundant portions (refactoring) 6.Repeat the process starting with Step #1

Slides based on Problem Solving with C++, 9th Edition, Walter Savitch 19 Scott Kristjanson – CMPT 135 – SFU Wk04.3 Slide 19 Debugging Debugging is the act of locating and correcting run-time and logic errors in programs Errors can be located in programs in a number of ways you may notice a run-time error (program termination) you may notice a logic error during execution Through rigorous testing, we hope to discover all possible errors. However, typically a few errors slip through into the final program A debugger is a software application that aids us in our debugging efforts

Slides based on Problem Solving with C++, 9th Edition, Walter Savitch 20 Scott Kristjanson – CMPT 135 – SFU Wk04.3 Slide 20 Simple Debugging using cout Simple debugging during execution can involve the use of strategic cout statements indicating the value of variables and the state of objects at various locations in the code the path of execution, usually performed through a series of “it got here” statements Consider the case of calling a method it may be useful to print the value of each parameter after the method starts this is particularly helpful with recursive methods

Slides based on Problem Solving with C++, 9th Edition, Walter Savitch 21 Scott Kristjanson – CMPT 135 – SFU Wk04.3 Slide 21 Debugging Concepts Formal debuggers generally allow us to set one or more breakpoints in the program. This allows to pause the program at a given point print the value of a variable or object step into or over a method execute the next single statement resume execution of the program

Slides based on Problem Solving with C++, 9th Edition, Walter Savitch 22 Scott Kristjanson – CMPT 135 – SFU Wk04.3 Slide 22 References: 1.Walter Savitch, Problem Solving with C++. Pearson, 9th Edition, 2014, ISBN T. DeMarco, Structured Analysis and System Specification, 1979, ISBN T DeMarco, Structured Analysis, Structural Design and Materials Conference 2001, Software Pioneers, Eds.: M. Broy, E. Denert, Springer Stevens, W., G. Meyers, and L. Constantine, Structured Design, IBM Systems Journal, Vol 13, No Fairley, Richard E., Software Engineering Concepts, McGraw-Hill, 1985, ISBN IBM DeveloperWorks website, UML basics: The class diagram,