CS4311 Spring 2011 Unit Testing Dr. Guoqiang Hu Department of Computer Science UTEP.

Slides:



Advertisements
Similar presentations
Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Advertisements

Chapter 14 Software Testing Techniques - Testing fundamentals - White-box testing - Black-box testing - Object-oriented testing methods (Source: Pressman,
Path Analysis Why path analysis for test case design?
Marking Schema question1: 40 marks question2: 40 marks question3: 20 marks total: 100 marks.
Chapter 6 Path Testing Software Testing
Whitebox Testing Fra: CS Fall Whitebox Testing AKA Structural, Basis Path Test Normally used at unit level Assumes errors at unit level are.
1 ECE 453 – CS 447 – SE 465 Software Testing & Quality Assurance Lecture 11 Instructor Paulo Alencar.
Unit Testing CS 4311 Hans Van Vliet, Software Engineering, Principles and Practice, 3rd edition, John Wiley & Sons, Chapter 13.
1 Ivan Marsic Rutgers University LECTURE 15: Software Complexity Metrics.
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
Chapter 4 Control Structures I. Objectives ► Examine relational and logical operators ► Explore how to form and evaluate logical (Boolean) expressions.
White Box Testing Techniques Dynamic Testing. White box testing(1) Source code is known and used for test design While executing the test cases, the internal.
CS 106 Introduction to Computer Science I 02 / 12 / 2007 Instructor: Michael Eckmann.
BASIS PATH TESTING ● By Tom McCabe ● McCabe, T., "A Software Complexity Measure," IEEE Trans. Software Engineering, vol. SE-2, December 1976, pp
Path testing Path testing is a “design structural testing” in that it is based on detailed design & the source code of the program to be tested. The methodology.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Software Systems Verification and Validation Laboratory Assignment 3
CMSC 345 Fall 2000 Unit Testing. The testing process.
Testing phases. Test data Inputs which have been devised to test the system Test cases Inputs to test the system and the predicted outputs from these.
CS4311 Spring 2011 Unit Testing Dr. Guoqiang Hu Department of Computer Science UTEP.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 20 Slide 1 Defect testing l Testing programs to establish the presence of system defects.
CSC 480 Software Engineering Lecture 14 Oct 16, 2002.
Path Testing + Coverage Chapter 9 Assigned reading from Binder.
Reference Paulo Alencar, University of Waterloo Frank Tsui, Southern Polytechnic State University.
Something to amuse you… CS UWO minutes.
1 Software Testing. 2 Path Testing 3 Structural Testing Also known as glass box, structural, clear box and white box testing. A software testing technique.
INTRUDUCTION TO SOFTWARE TESTING TECHNIQUES BY PRADEEP I.
White-box Testing.
CS 217 Software Verification and Validation Week 7, Summer 2014 Instructor: Dong Si
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 ‏ Control Structures.
1 Program Testing (Lecture 14) Prof. R. Mall Dept. of CSE, IIT, Kharagpur.
BASIS PATH TESTING.
Chapter 8 Path Testing. Path testing Path testing is a “design structural testing” in that it is based on detailed design & the source code of the program.
SOFTWARE TESTING. Introduction Software Testing is the process of executing a program or system with the intent of finding errors. It involves any activity.
White Box Testing by : Andika Bayu H.
1 Test Coverage Coverage can be based on: –source code –object code –model –control flow graph –(extended) finite state machines –data flow graph –requirements.
White-Box Testing Techniques I Prepared by Stephen M. Thebaut, Ph.D. University of Florida Software Testing and Verification Lecture 7.
Dynamic White-Box Testing What is code coverage? What are the different types of code coverage? How to derive test cases from control flows?
White-Box Testing Statement coverage Branch coverage Path coverage
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
CS223: Software Engineering Lecture 26: Software Testing.
CS 106 Introduction to Computer Science I 02 / 15 / 2008 Instructor: Michael Eckmann.
BASIS PATH TESTING.
SOFTWARE PRESENTATION ON Path Testing And Decision To Decision Path
Software Testing.
White-Box Testing Pfleeger, S. Software Engineering Theory and Practice 2nd Edition. Prentice Hall, Ghezzi, C. et al., Fundamentals of Software Engineering.
Software Testing.
Control Flow Testing Handouts
Software Engineering (CSI 321)
Graph Coverage Criteria CS 4501 / 6501 Software Testing
Chapter 5 Decisions. Chapter 5 Decisions ssential uestion: How are Boolean expressions or operators used in everyday life?
CONTROL FLOW TESTING.
Structural testing, Path Testing
Types of Testing Visit to more Learning Resources.
White-Box Testing.
CHAPTER 4 Test Design Techniques
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Software Testing (Lecture 11-a)
Types, Truth, and Expressions (Part 2)
Types, Truth, and Expressions (Part 2)
CS212D: Data Structures Week 5-6 Linked List.
Sudipto Ghosh CS 406 Fall 99 November 16, 1999
Graph Coverage Criteria CS 4501 / 6501 Software Testing
White-Box Testing Techniques I
Computer Science Core Concepts
Types, Truth, and Expressions (Part 2)
Whitebox Testing.
Chapter 3: Selection Structures: Making Decisions
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Unit III – Chapter 3 Path Testing.
Presentation transcript:

CS4311 Spring 2011 Unit Testing Dr. Guoqiang Hu Department of Computer Science UTEP

Statement Coverage Every statement gets executed at least once Every node in the CFG gets visited at least once Statement coverage is the most basic (weakest) coverage Groups of 2 in 3 minutes: The number of paths needed for statement coverage?

Branch Coverage Also known as decision/edge coverage, stronger than statement coverage: Every decision is made true and false at least once each Every edge in a CFG of the program gets traversed at least once Groups of 2 in 2 minutes: The number of paths needed for branch coverage?

Condition Coverage Every condition in a decision (a boolean expression) is made true and false by every possible combination. For example: (x and y) x = true, y = true x= false, y= true x = true, y= false x = false, y = false Condition coverage is not necessarily stronger than branch coverage: There are pathological cases where you can achieve condition coverage but not branch coverage However, under most circumstances, achieving condition coverage achieves branch coverage One way to determine the number of paths is to break the compound conditional into atomic conditionals when writing CFG

Path Coverage A path is a sequence of statements from beginning to end A path is sequence of branches from beginning to end A path is a sequence of edges from beginning to end Every distinct path through code is executed at least once Groups of 2 in 2 minutes: The number of paths needed for path coverage?

Path Coverage: Exercise Groups of 2 in 2 minutes: Find the number of paths, and the paths, needed for path coverage 1. read (x) 2. read (z) 3. if x  0 then begin 4. y  x * z; 5. x  z end 6. else print ‘Invalid’ 7. if y > 1 then 8. print y 9. else print ‘Invalid’ Test Paths: 4 1, 2, 3, 4, 5, J1, 7, 8, J2 1, 2, 3, 4, 5, J1, 7, 9, J2 1, 2, 3, 6, J1, 7, 8, J2, 1, 2, 3, 6, J1, 7, 9, J2 1,2,3 4,5 Join Join2 9 Normally, it is not possible to calculate the total number of paths.

Path Coverage: Linearly Independent Paths A linearly independent path is an end-to-end path that introduces at least one new set of process statements or a new condition. Consider the following encoding: Label each edge in the CFG with a positive integer Describe a path using a vector where each element of the vector is the number of times the edge at that index is traversed For example: A D 1 BC The path ABD (or, p13) can be written as: [1, 0, 1, 0] Let’s further consider: Paths can be linearly combined by operations like: addition, subtraction, or scalar multiplication of path vectors All the path vectors form a vector space In this vector space, a basis set of vectors can be found, such that: in this basis set, each member cannot be derived from the other members; but, all the rest of vectors in the space can be derived from this basis set

Path Coverage: Basis Set (or, Base) Exercise 1