$30 off During Our Annual Pro Sale. View Details »

CSE360 Flipped Lecture 09

CSE360 Flipped Lecture 09

Introduction to Software Engineering
Software Testing
(202010)

Javier Gonzalez-Sanchez
PRO

June 09, 2020
Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Programming

Transcript

  1. 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

    View Slide

  2. 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

    View Slide

  3. 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.

    View Slide

  4. 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!

    View Slide

  5. 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

    View Slide

  6. Second Midterm

    View Slide

  7. 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

    View Slide

  8. 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)

    View Slide

  9. 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

    View Slide

  10. 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)

    View Slide

  11. Software Testing

    View Slide

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

    View Slide

  13. 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.

    View Slide

  14. 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

    View Slide

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

    View Slide

  16. Unit Testing

    View Slide

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

    View Slide

  18. 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

    View Slide

  19. 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

    View Slide

  20. 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

    View Slide

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

    View Slide

  22. 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

    View Slide

  23. 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 (xx:= x+3;
    y:= y+2;
    Control Flow Graph

    View Slide

  24. 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.

    View Slide

  25. Statement and Decision Coverage

    View Slide

  26. 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

    View Slide

  27. 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

    View Slide

  28. 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

    View Slide

  29. 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

    View Slide

  30. To be continued…

    View Slide

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

    View Slide

  32. 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.

    View Slide