Workshop on Integrating Software Testing into Programming Courses (WISTPC14:2) Friday July 18, 2014 Introduction to Software Testing.

Slides:



Advertisements
Similar presentations
Software Verification
Advertisements

CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
Black box testing  Black box tests focus on the input/output behavior of the component  Black-box tests do not deal with the internal aspects of the.
Software testing.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing 2.
Testing Team exercise Have each team member contribute answers: –Do you test your code? If no, why not? If yes: When? How? How often? –What is your team’s.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Software Testing Verification and validation planning Software inspections Software Inspection vs. Testing Automated static analysis Cleanroom software.
Dr. Pedro Mejia Alvarez Software Testing Slide 1 Software Testing: Building Test Cases.
System/Software Testing
Introduction to Software Testing Chapter 5.2 Program-based Grammars Paul Ammann & Jeff Offutt
CS 217 Software Verification and Validation Week 6, Summer 2014 Instructor: Dong Si
CMSC 345 Fall 2000 Unit Testing. The testing process.
Chapter 12: Software Testing Omar Meqdadi SE 273 Lecture 12 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
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.
Overview of Software Testing 07/12/2013 WISTPC 2013 Peter Clarke.
Introduction to Software Testing Chapter 1 Introduction
©Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing.
Introduction to Software Testing
Coverage Literature of software testing is primarily concerned with various notions of coverage Four basic kinds of coverage: Graph coverage Logic coverage.
Software Testing Testing types Testing strategy Testing principles.
Agenda Introduction Overview of White-box testing Basis path testing
SWE 637: Test Criteria and Definitions Tao Xie Prepared based on Slides by ©Paul Ammann and Jeff Offutt Revised by Tao Xie.
637 – Introduction (Ch 1) Introduction to Software Testing Chapter 1 Jeff Offutt Information & Software Engineering SWE 437 Software Testing
Black Box Testing Techniques Chapter 7. Black Box Testing Techniques Prepared by: Kris C. Calpotura, CoE, MSME, MIT  Introduction Introduction  Equivalence.
Test Drivers and Stubs More Unit Testing Test Drivers and Stubs CEN 5076 Class 11 – 11/14.
Test Coverage CS-300 Fall 2005 Supreeth Venkataraman.
637 – Introduction (Ch 1) Introduction to Software Testing Chapter 1 Jeff Offutt Information & Software Engineering SWE 437 Software Testing
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 22 Slide 1 Software Verification, Validation and Testing.
Today’s Agenda  HW #1  Finish Introduction  Input Space Partitioning Software Testing and Maintenance 1.
1 Introduction to Software Testing. Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Chapter 1 2.
Introduction to Software Testing Chapters 1-5 Coverage Summary Paul Ammann & Jeff Offutt
Introduction to Software Testing Paul Ammann & Jeff Offutt Updated 24-August 2010.
Introduction to Software Testing 06/23/2010 WISTPC 2010 Peter J. Clarke.
Introduction to Software Testing. OUTLINE Introduction to Software Testing (Ch 1) 2 1.Spectacular Software Failures 2.Why Test? 3.What Do We Do When We.
637 – Introduction (Ch 1) Introduction to Software Testing Chapter 1 Jeff Offutt Information & Software Engineering SWE 637 Software Testing
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
CS451 Lecture 10: Software Testing Yugi Lee STB #555 (816)
Dynamic Testing.
HNDIT23082 Lecture 09:Software Testing. Validations and Verification Validation and verification ( V & V ) is the name given to the checking and analysis.
Chapter 12: Software Testing Omar Meqdadi SE 273 Lecture 12 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
637 – Introduction (Ch 1) Introduction to Software Testing Chapter 1 Jeff Offutt Information & Software Engineering SWE 637 Software Testing
Introduction to Software Testing Chapter 1 Introduction Paul Ammann & Jeff Offutt
Testing Overview Software Reliability Techniques Testing Concepts CEN 4010 Class 24 – 11/17.
637 – Introduction (Ch 1) Introduction to Software Testing Chapter 1 Jeff Offutt Information & Software Engineering SWE 637 Software Testing
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.
Defect testing Testing programs to establish the presence of system defects.
CS223: Software Engineering Lecture 26: Software Testing.
Testing Integral part of the software development process.
Introduction to Software Testing (2nd edition) Chapter 5 Criteria-Based Test Design Paul Ammann & Jeff Offutt
Testing Tutorial 7.
Software Testing.
Paul Ammann & Jeff Offutt
Input Space Partition Testing CS 4501 / 6501 Software Testing
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
Faults, Errors, Failures CS 4501 / 6501 Software Testing
Structural testing, Path Testing
Types of Testing Visit to more Learning Resources.
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Introduction to Software Testing Chapter 2 Model-Driven Test Design
Software Testing (Lecture 11-a)
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Guide for writing a Software Testing Document
Paul Ammann & Jeff Offutt
UNIT-4 BLACKBOX AND WHITEBOX TESTING
Presentation transcript:

Workshop on Integrating Software Testing into Programming Courses (WISTPC14:2) Friday July 18, 2014 Introduction to Software Testing

What is software testing? Software testing is the process of operating software under specified conditions, observing or recording the results and making an evaluation of some aspect of the software. (IEEE/ANSI std ) 4

3 Overview of Testing - Terminology Software testing is the dynamic verification of the behavior of a program on a finite set of test cases, suitably selected from the usually infinite execution domain, against the expected behavior. (Guide to the Software Engineering Body of Knowledge 2004 Version)

How much testing is enough? Testing can show the presence of errors but not their absence. – Edsger Dijkstra 4

Errors Discovered over Time Number of errors 5 Time

Introduction to Software Testing (Ch 1), © Ammann & Offutt 6 Important Terms Validation & Verification Validation: – The process of evaluating software at the end of software development to ensure compliance with intended usage Verification: – The process of determining whether the products of a given phase of the software development process fulfill the requirements established during the previous phase IV&V stands for “independent verification and validation ”

Introduction to Software Testing (Ch 1), © Ammann & Offutt 7 Static and Dynamic Testing Static Testing: – Testing without executing the program. This include software inspections and some forms of analyses. Dynamic Testing: – Testing by executing the program with real inputs

Introduction to Software Testing (Ch 1), © Ammann & Offutt 8 Software Faults, Errors & Failures Software Fault: – A static defect in the software Software Error: – An incorrect internal state that is the manifestation of some fault Software Failure: – External, incorrect behavior with respect to the requirements or other description of the expected behavior

Introduction to Software Testing (Ch 1), © Ammann & Offutt 9 Testing & Debugging Testing: – Finding inputs that cause the software to fail Debugging: – The process of finding a fault given a failure

Introduction to Software Testing (Ch 1), © Ammann & Offutt 10 Fault & Failure Model Three conditions necessary for a failure to be observed 1.Reachability : The location or locations in the program that contain the fault must be reached 2.Infection : The state of the program must be incorrect 3.Propagation : The infected state must propagate to cause some output of the program to be incorrect

Introduction to Software Testing (Ch 1), © Ammann & Offutt 11 Test Case Test Case Values: – The values that directly satisfy one test requirement Expected Results: – The result that will be produced when executing the test if the program satisfies it intended behavior

Testing Concepts Test case components: 1.Name – identifies the test case, it is a good idea to derive the name from the requirement being tested. 2.Purpose – states the purpose of the test and relates it to the requirement (or scenario). 3.Test set up – describe the h/w and s/w and environment required for a successful test. 4.Input – description of the input data or commands. 5.Expected output (or Oracle) – expected test results against which the output of the test is compared.

What is a successful test case? One that produces expected results? OR One that produces a failure? 13

Errors Discovered over Time Number of errors 14 Time

Introduction to Software Testing (Ch 1), © Ammann & Offutt 15 Observability and Controllability Software Observability: – How easy it is to observe the behavior of a program in terms of its outputs, effects on the environment and other hardware and software components Software that affects hardware devices, databases, or remote files have low observability

Software Controllability: – How easy it is to provide a program with the needed inputs, in terms of values, operations, and behaviors Easy to control software with inputs from keyboards Inputs from hardware sensors or distributed software is harder Data abstraction reduces controllability and observability 16

Levels of Testing Unit Testing – Refers to tests that verify the functionality of a specific section of code, usually at the function level. In an object-oriented environment, this is usually at the class level, and the minimal unit tests include the constructors and destructors. (wikipedia, 2010) Integration Testing – Is any type of software testing that seeks to verify the interfaces between components against a software design. Components may be integrated in an iterative way or all together ("big bang"). (wikipedia, 2010)

Levels of Testing System Testing – Testing a completely integrated system to verify that it meets its requirements. (wikipedia, 2010) See 18

Unit Testing Focuses on the building blocks of the software system i.e., objects and subsystems. Many unit testing techniques have been devised including: equivalence testing, state-based testing, boundary testing, domain testing, control flow- based testing (statement, branch). 19

Introduction to Software Testing (Ch 1), © Ammann & Offutt 20 White-box and Black-box Testing Black-box testing: – Deriving tests from external descriptions of the software, including specifications, requirements, and design White-box testing: – Deriving tests from the source code internals of the software, specifically including branches, individual conditions, and statements

Criteria Based on Structures 1.Graphs 2.Logical expressions 3.Input domain characteristics 4.Syntactic structures – Ammann & Offutt, Introduction to Software Testing 21

Introduction to Software Testing (Ch 1), © Ammann & Offutt 22 1.Graphs 2.Logical Expressions 3.Input Domain Characterization 4.Syntactic Structures (not X or not Y) and A and B if (x > y) z = x - y; else z = 2 * x; A: {0, 1, >1} B: {600, 700, 800} C: {swe, cs, isa, infs} Structures : Four ways to model software

Introduction to Software Testing (Ch 1), © Ammann & Offutt23 1. Graph Coverage – Structural Node (Statement) Cover every node This graph may represent statements & branches methods & calls components & signals states and transitions Edge (Branch) Cover every edge Path Cover every path …

Introduction to Software Testing (Ch 1), © Ammann & Offutt24 Defs & Uses Pairs (x, 1, (1,2)), (x, 1, (1,3)) (y, 1, 4), (y, 1, 6) (a, 2, (5,6)), (a, 2, (5,7)), (a, 3, (5,6)), (a, 3, (5,7)), (m, 4, 7), (m, 6, 7) 1. Graph Coverage – Data Flow This graph contains: defs: nodes & edges where variables get values uses: nodes & edges where values are accessed def = {x, y} def = {a, m} def = {a} def = {m} use = {x} use = {a} use = {y} use = {m} use = {y} All Defs Every def used once 1, 2, 5, 6, 7 1, 3, 4, 3, 5, 7 All Uses Every def “reaches” every use 1, 2, 5, 6, 7 1, 2, 5, 7 1, 3, 5, 6, 7 1, 3, 5, 7 1, 3, 4, 3, 5,7

Introduction to Software Testing (Ch 1), © Ammann & Offutt25 1. Graph - FSM Example Memory Seats in a Lexus ES 300 Driver 1 Configuration Driver 2 Configuration [Ignition = off] | Button2 [Ignition = off] | Button1 Modified Configuration sideMirrors ()[Ignition = on] | lumbar ()[Ignition = on] | seatBottom ()[Ignition = on] | seatBack () [Ignition = on] | New Configuration Driver 1 New Configuration Driver 2 [Ignition = on] | Reset AND Button1 [Ignition = on] | Reset AND Button2 Ignition = off (to Modified) Guard (safety constraint) Trigger (input)

26 Control Flow Adequacy Criteria cont Example: Source code public int Fun(int x){ k = 0; while (x <= 10 && k < 3){ if (x%2 != 0) k = k + 1; x = x + 1; } if (x < 0){ x = 10; k = 0; } return k; } K=0 x<=10 && k<3 x%2 != 0 x=x+1 k=k+1 return k B C D E F I Entry Flow graph A X<0 X = 10 K = 0 T F T T F F G H

27 Unit Testing – Statement Coverage 1.Statement coverage – A set P of execution paths satisfies the statement coverage criterion iff for all nodes n in the FG, there is at least one path p in P s.t. n is on the path p. Whitebox testing technique. Generate test data to execute every stmt in the program at least once. Exercise: Indentify value(s) of x to execute every stmt in Fun(int x) at least once.

28 Unit Testing – Branch Coverage 2.Branch coverage – A set P of execution paths satisfies the branch coverage criterion iff for all edges e in the FG, there is at least one path p in P s.t. p contains edge e. Whitebox testing technique. Generate test data to exercise the true and false outcomes of every decision. Exercise: Indentify value(s) of x to execute every branch in Fun(int x) at least once.

Introduction to Software Testing (Ch 1), © Ammann & Offutt Logical Expressions ( (a > b) or G ) and (x < y) Transitions Software Specifications Program Decision Statements Logical Expressions

Introduction to Software Testing (Ch 1), © Ammann & Offutt Logical Expressions Predicate Coverage : Each predicate must be true and false –( (a>b) or G ) and (x < y) = True, False Clause Coverage : Each clause must be true and false – (a > b) = True, False – G = True, False – (x < y) = True, False Combinatorial Coverage : Various combinations of clauses – Active Clause Coverage: Each clause must determine the predicate’s result ( (a > b) or G ) and (x < y)

Introduction to Software Testing (Ch 1), © Ammann & Offutt Logic – Active Clause Coverage ( (a > b) or G ) and (x < y) 1 T F T 2 F F T duplicate 3 F T T 4 F F T 5 T T T 6 T T F With these values for G and (x b) determines the value of the predicate

Introduction to Software Testing (Ch 1), © Ammann & Offutt Input Domain Characterization Describe the input domain of the software – Identify inputs, parameters, or other categorization – Partition each input into finite sets of representative values – Choose combinations of values System level – Number of students { 0, 1, >1 } – Level of course { 600, 700, 800 } – Major { swe, cs, isa, infs } Unit level – Parameters F (int X, int Y) – Possible values X: { 2 }, Y : { 10, 20, 30 } – Tests F (-5, 10), F (0, 20), F (1, 30), F (2, 10), F (5, 20)

Unit Testing – Boundary Analysis Test cases are generated using the extremes of the input domain, e.g. maximum, minimum, just inside/outside boundaries, typical values, and error values. It is similar to Equivalence Partitioning but focuses on "corner cases“. Exercise: write test case input using boundary analysis for the getNumberDaysInMonth() method. 33

Unit Testing – Equivalence Partitioning Equivalence partitioning is a blackbox testing technique that minimizes the number of test cases. Possible inputs are partitioned into equivalence testing classes, and a test case is selected from each class. Assumption - system behaves in a similar way for all members of an equiv. class. Criteria used to determine equivalence classes: coverage, disjointedness, representation. 34

Unit Testing – Equivalence Partitioning Equivalence classValue for month inputValue for year input Months with 31 days, non-leap yrs.7 (July)1901 Months with 31 days, leap yrs.7 (July)1904 Months with 30 days, non-leap yrs.6 (June)1901 Months with 30 days, leap yrs.6 (June)1904 Months with 28 or 29 days, non-leap yrs.2 (February)1901 Months with 28 or 29 days, leap yrs.2 (February) Example: Valid inputs to test the getNumberDaysInMonth() method

Introduction to Software Testing (Ch 1), © Ammann & Offutt Syntactic Structures Based on a grammar, or other syntactic definition Primary example is mutation testing 1.Induce small changes to the program: mutants 2. Find tests that cause the mutant programs to fail: killing mutants 3.Failure is defined as different output from the original program 4. Check the output of useful tests on the original program Example program and mutants if (x > y) z = x - y; else z = 2 * x; if (x > y)  if (x >= y) z = x - y;  z = x + y;  z = x – m; else z = 2 * x;

Miami University, Oxford OH 37