Slide 1

Slide 1 text

CSE 360 Introduction to Software Engineering Lecture 09: Software Testing Dr. Javier Gonzalez-Sanchez [email protected] javiergs.engineering.asu.edu | javiergs.com PERALTA 230U Office Hours: By appointment

Slide 2

Slide 2 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 2 Announcements (This Week) • Assignment 04 (Junit Test) • A Sample Exam is available for you to test your access to Lock Down Browser. It has no value, and you can take it as many times as needed. Test your system ASAP

Slide 3

Slide 3 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 3 Announcements (Next Week) • Second Midterm Exam Next Week. During the lecture time. No lecture that day. Lockdown browser will not allow you to use Zoom • Exercise 06 will open. It is about Cyclomatic Complexity.

Slide 4

Slide 4 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 4 Important § Review, Understand, and Follow the Online Proctored Exam Guidelines § During the exam, show your environment. § It is a CLOSED BOOK exam. Do not use any material § Scratch paper is allowed. Show it on camera when you show your environment!

Slide 5

Slide 5 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 5 Email Etiquette • What course? CSE 360 • What section? Tuesday or Thursday • Is it about a grade? First, contact the TA • Is it about a medical condition? Include documentation • Use your ASU email

Slide 6

Slide 6 text

Second Midterm

Slide 7

Slide 7 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 7 Note The following is a summary of the most relevant ideas. But the exam is not limited to these, i.e., The following IS NOT a comprehensive list

Slide 8

Slide 8 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 8 It is Comprehensive 1. Concepts 2. Process Models 3. Requirement Engineering 4. Diagrams (Use Case, Activity, State, 5. Software Design (Class diagram)

Slide 9

Slide 9 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 9 New topics 1. Diagrams (Sequence Diagram) 2. Version Control and GitHub 3. Abstraction, Encapsulation, Relationships, Polymorphism, Cohesion, Coupling 4. Design Patterns: Observer and Decorator 5. Algorithms: Decision tables and trees

Slide 10

Slide 10 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 10 New topics 6. Flowchart and Nassi-Schneiderman Diagrams 7. Pseudocode 8. Software Architecture 9. Architectural Patterns 10.Software Testing (Unit Testing)

Slide 11

Slide 11 text

Software Testing

Slide 12

Slide 12 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 12 Activities 1. Requirements 2. Modeling or Design 3. Construction or Coding 4. Testing 5. Deployment or Delivery

Slide 13

Slide 13 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 13 Software Testing § Testing is intended to show that a program does what it is intended to do (validation) and to discover program defects (verification) before it is put into use. § When you test software, you execute a program using artificial data. § You check the results of the test run for errors, anomalies or information about the program’s non-functional attributes. § Testing can reveal the presence of errors NOT their absence. § Testing quality is only as good as the test cases you give it.

Slide 14

Slide 14 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 14 Software Testing developer independent tester Understands the system but, will test "gently" and, is driven by "delivery" Must learn about the system, but, will attempt to break it and, is driven by quality

Slide 15

Slide 15 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 15 Software Testing

Slide 16

Slide 16 text

Unit Testing

Slide 17

Slide 17 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 17 Unit Testing

Slide 18

Slide 18 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 18 Black Box Testing Knowing the specified function that a product has been designed to perform, tests to demonstrate each function is fully operational while at the same time searching for errors in each function CHAPTER 8 SOFTWARE TESTING 18

Slide 19

Slide 19 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 19 Black Box Focus Attempt to find errors in following categories § Incorrect or missing functions § Interface errors § Errors in data structures or external database access § Performance errors § Initialization and termination errors Performed in later stages of testing 19 10/29/20 CHAPTER 8 SOFTWARE TESTING

Slide 20

Slide 20 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 20 White Box Testing Knowing the internal workings of a product, tests can be conducted to ensure that internal operations are performed according to specifications i.e., the goal is to ensure that all statements and conditions have been executed at least once CHAPTER 8 SOFTWARE TESTING 10/29/20

Slide 21

Slide 21 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 21 White Box | Selective Testing loop < 20 X Selected path

Slide 22

Slide 22 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 22 White Box | Control-flow-based Testing • Step 1: from the source, create a graph describing the flow of control, called the control flow graph (extracted from the source code) manually or automatically) • Step 2: design test cases to cover certain elements of this graph (Nodes, edges, paths) 22 10/29/20 CHAPTER 8 SOFTWARE TESTING

Slide 23

Slide 23 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 23 if (x+y < 100) s:= s+x+y; else d:= d+x-y; } 1 2 3 4 5 6 7 8 s:=0; d:=0; while (x

Slide 24

Slide 24 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 24 Coverage § Statement Coverage: every statement in the code is executed at least once. § Decision or Branch Coverage: each one of the possible branch from each decision point is executed at least once and thereby ensuring that all reachable code is executed: (1) True and false branches of each IF; (2) The two branches corresponding to the condition of a loop; (3) All alternatives in a SWITCH statement § Condition Coverage : each boolean expression must be evaluated to true and false at least once. For example: • Path Coverage: every path is executed at least once.

Slide 25

Slide 25 text

Statement and Decision Coverage

Slide 26

Slide 26 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 26 Decision or Branch coverage • Decision or Branch coverage has been considered a necessary testing minimum. To achieve it: pick a set of start-to-end paths (in the CFG) that cover all branches, and then write test cases to execute these paths

Slide 27

Slide 27 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 27 Example 1 // test case 1: values a = 5; b = 5; if(a==5){ if(b==5){ System.out.println("Hi”); } } // 100% statement coverage // 50% branch coverage 27 10/29/20 CHAPTER 8 SOFTWARE TESTING

Slide 28

Slide 28 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 28 Example 2 // test case 1: values a = 5; b = 5; if(a==5 || b==5){ System.out.println("Bye"); } else { if(b==5){ System.out.println("Hi"); } } // 50% statement coverage // ??% branch coverage 28 10/29/20 CHAPTER 8 SOFTWARE TESTING

Slide 29

Slide 29 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 29 Example 2 // use another test case // test case 2: values a = 0; b = 0; c = 5; if(a==5 || b==5){ System.out.println("Bye"); } else { if(c==5){ System.out.println("Hi"); } } // 100% statement coverage (with 2 test cases) // ??% branch coverage (with 2 test cases) 29 10/29/20 CHAPTER 8 SOFTWARE TESTING

Slide 30

Slide 30 text

To be continued…

Slide 31

Slide 31 text

Javier Gonzalez-Sanchez | CSE360 | Fall 2020 | 31 Homework Complete This Week’s Hybrid Activities

Slide 32

Slide 32 text

CSE360 – Introduction to Software Engineering Javier Gonzalez-Sanchez [email protected] Summer 2020 Disclaimer. These slides can only be used as study material for the class CSE360 at ASU. They cannot be distributed or used for another purpose.