Introduction to Software Testing CS 3250 Software Testing

  • Slides: 23
Download presentation
Introduction to Software Testing CS 3250 Software Testing Fall 2020 – University of Virginia

Introduction to Software Testing CS 3250 Software Testing Fall 2020 – University of Virginia [Ammann and Offutt, “Introduction to Software Testing, ” Ch. 1, Ch. 2. 1] © Praphamontripong 1

Bug? “ ‘Bug’ – as such little faults and difficulties are called – show

Bug? “ ‘Bug’ – as such little faults and difficulties are called – show themselves, and months of anxious watching, study, and labor are requisite before commercial success – or failure – is certainly reached. ” [Thomas Edison, 1878] [Ref: Did You Know? Edison Coined the Term “Bug”, http: //theinstitute. ieee. org/tech-history/technology-history/didyou-know-edison-coined-the-term-bug, IEEE 2013] “A software bug is an error, flaw, failure or fault in a computer program or system that causes it to produce an incorrect or unexpected result, or to behave in unintended ways. ” [Ref: https: //en. wikipedia. org/wiki/Software_bug] • Bug is used informally. • Fault? Error? Or failure? • This course will try to use words that have precise, defined, and unambiguous meaning – and avoid using the term “bug” Fall 2020 – University of Virginia BUG © Praphamontripong 2

Fault, Error, and Failure • Fault: a static defect in the software’s source code

Fault, Error, and Failure • Fault: a static defect in the software’s source code Cause of a problem • Error: An incorrect internal state that is the manifestation of some fault Erroneous program state caused by execution of the defect • Failure: External, incorrect behavior with respect to the requirements or other descriptions of the expected behavior Propagation of erroneous state to the program outputs Fall 2020 – University of Virginia © Praphamontripong 3

What is Software Testing? • Testing = process of finding input values to check

What is Software Testing? • Testing = process of finding input values to check against a software (focus of this course) Test case consists of test values and expected results Goal – reveal faults • Debugging = process of finding a fault given a failure Test values (inputs) Program Actual results vs Expected results 1. Testing is fundamentally about choosing finite sets of values from the input domain of the software being tested 2. Given the test inputs, compare the actual results with the expected results Fall 2020 – University of Virginia © Praphamontripong 4

First Example (Testing) • Imagine we are testing a simply “add” functionality of a

First Example (Testing) • Imagine we are testing a simply “add” functionality of a calculator program (e. g. , the adder() function below) • The “add” functionality takes 2 numbers that the user enters • Each number should be one or two digits • The program displays the sum of the 2 numbers • Write all test cases for the adder(). What are test case inputs? How many test cases do we need? def adder(): n 1 = int(input('Enter number 1: ')) n 2 = int(input('Enter number 2: ')) return n 1 + n 2 end = 'n' while end != 'y': print('sum =', adder()) end = input('Enter 'y' to end the program: ') Fall 2020 – University of Virginia © Praphamontripong 5

First Example (Debugging) • Given a failure, find a fault, fix the fault Rubber

First Example (Debugging) • Given a failure, find a fault, fix the fault Rubber duck debugging Talk to me Fall 2020 – University of Virginia © Praphamontripong 6

Testing Categories Static testing • Dynamic testing Testing without executing the program Software inspection

Testing Categories Static testing • Dynamic testing Testing without executing the program Software inspection and some forms of analysis Effective at finding certain kinds of problems such as problems that can lead to faults when the program is modified • • Testing by executing the program with real inputs • Unit testing, integration testing, system testing, acceptance testing, … Inspection, walkthrough, code review, informal review, … Fall 2020 – University of Virginia © Praphamontripong 7

Testing Categories (2) White-box testing Gray-box testing Black-box testing Test with complete information of

Testing Categories (2) White-box testing Gray-box testing Black-box testing Test with complete information of the software (architecture, how components interact, functions and operations, code, rationale, …) Test with incomplete information of the software or limited knowledge of internal details (may know how components interact but not have detailed knowledge about internal program functions, source code, rationale, …) Test from the outside (functionality and behavior). Not require source code, architecture, detailed knowledge about internal program functions, rationale, …) Fall 2020 – University of Virginia © Praphamontripong 8

White-box vs. Black-box • Which one should we use? • Each technique has its

White-box vs. Black-box • Which one should we use? • Each technique has its strengths – use both Generally, first use black-box Then, white-box for missed code • Accept that we may not be able to detect all faults When to stop? ? Adequacy Coverage level Coverage criteria provides “stopping rule” Fall 2020 – University of Virginia © Praphamontripong 9

Testing Categories (3) Functional testing • • Non-functional testing Unit testing Integration testing System

Testing Categories (3) Functional testing • • Non-functional testing Unit testing Integration testing System testing Smoke testing Acceptance testing (Alpha / Beta Agile testing Regressing testing Continuous integration testing … and many more … Fall 2020 – University of Virginia • • Performance testing Load testing Stress testing Security testing Compatibility testing Reliability testing Usability testing Compliance testing … and many more … © Praphamontripong 10

Validation and Verification (IEEE) • Validation : The process of evaluating software at the

Validation and Verification (IEEE) • Validation : The process of evaluating software at the end of software development to ensure compliance with intended usage Not done by developers, but by experts in the intended usage of the software • 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 Requires technical background on the software, normally done by developers at the various stages of development IV&V stands for “independent verification and validation” Fall 2020 – University of Virginia © Praphamontripong 11

Testing and SW Development Lifecycle Requirements Analysis Architectural Design Acceptance Test Design Information System

Testing and SW Development Lifecycle Requirements Analysis Architectural Design Acceptance Test Design Information System Test Subsystem Design Detailed Design Implementation Integration Test Module Test Unit Test Check if software does what the user needs Check overall behavior w. r. t. specs Check interface between modules in the same subsystem Check interactions of units and associated data structures Check each unit (method) individually [based in part on AO, p. 23] Fall 2020 – University of Virginia © Praphamontripong 12

Testing and SW Development Lifecycle Requirements Analysis Architectural Design Acceptance Test Design Information System

Testing and SW Development Lifecycle Requirements Analysis Architectural Design Acceptance Test Design Information System Test Subsystem Design Detailed Design Implementation Validation Integration Test Module Test Verification Unit Test [based in part on AO, p. 23] Fall 2020 – University of Virginia © Praphamontripong 13

Goals based on Test Process Maturity Beizer’s scale for test process maturity § Level

Goals based on Test Process Maturity Beizer’s scale for test process maturity § Level 0: There is no difference between testing and debugging § Level 1: The purpose of testing is to show correctness § Level 2: The purpose of testing is to show that the software does not work § Level 3: The purpose of testing is not to prove anything specific, but to reduce the risk of using the software § Level 4: Testing is a mental discipline that helps all IT professionals develop higher quality software [AO, p. 9] Fall 2020 – University of Virginia © Praphamontripong 14

Level 0 – Testing is Debugging § Level 0: Testing is the same as

Level 0 – Testing is Debugging § Level 0: Testing is the same as debugging § Not distinguish between incorrect behavior and mistakes in the program § Not help develop software that is reliable § Adopted by most CS students § Get programs to compile § Debug with few arbitrarily chosen inputs or those provided by instructors [image: http: //softwaretestingandqa. blogspot. com/2007/12/software-bug. html] Fall 2020 – University of Virginia © Praphamontripong 15

Levels 1 – Software Works § Level 1: Purpose is to show correctness (developer-biased

Levels 1 – Software Works § Level 1: Purpose is to show correctness (developer-biased view) § Correctness is impossible to establish or demonstrate § What do we know if “no failures”? § Good software? § Bad tests? § No strict goal, no stopping rule or formal test technique § No quantitatively way to evaluate; test managers are powerless [image: http: //simply-the-test. blogspot. com/2010/] Fall 2020 – University of Virginia © Praphamontripong 16

Levels 2 – Software Doesn’t Work § Level 2: Purpose is to show failure

Levels 2 – Software Doesn’t Work § Level 2: Purpose is to show failure (tester-biased view) § A negative view puts testers and developers into an adversarial relationship – bad team morale § What do we know if “no failures”? Good software? Bad tests? [image: http: //simply-the-test. blogspot. com/2010/] Fall 2020 – University of Virginia © Praphamontripong 17

“Mature” Testing Correctness cannot generally be achieved or demonstrated through testing. Testing can only

“Mature” Testing Correctness cannot generally be achieved or demonstrated through testing. Testing can only show the presence of failure, not the absence. Developers and testers should be on the same boat. Fall 2020 – University of Virginia © Praphamontripong 18

Levels 3 – Risk Reduction § Level 3: Purpose is to reduce the risk

Levels 3 – Risk Reduction § Level 3: Purpose is to reduce the risk of using the software § There are risks when using software § Some may be small with unimportant consequences § Some may be big with important consequences, or even catastrophic § Testers and developers cooperate to reduce risk Fall 2020 – University of Virginia © Praphamontripong 19

Levels 4 – Quality Improvement § Level 4: Purpose is to increase quality of

Levels 4 – Quality Improvement § Level 4: Purpose is to increase quality of the software § Testing should be an integral part of the development process § Testers become technical leaders, measuring and improving software quality § Help developers improve the ability to produce quality software § Train developers § Testers and developers cooperate to improve the quality § Example: Spell checker § Purpose: to improve our ability to spell § Change of mindset: “find misspelled words” “improve ability to spell” Fall 2020 – University of Virginia © Praphamontripong 20

How “Mature” is Your Testing? Are you at level 0, 1, 2, 3, or

How “Mature” is Your Testing? Are you at level 0, 1, 2, 3, or 4? We hope to train you to become “change agents” (level 4) Fall 2020 – University of Virginia © Praphamontripong 21

Tactical Goals: Each Test ”If you don’t know why you’re conducting each test, it

Tactical Goals: Each Test ”If you don’t know why you’re conducting each test, it won’t be very helpful” – Jeff Offutt § What is objective and requirement of each test? § What fact does each test try to verify? § What are threshold reliability requirements? § What are the planned coverage levels? § How many tests are needed? Fall 2020 – University of Virginia © Praphamontripong 22

Wrap-up • A tester’s goal is to eliminate faults as early as possible •

Wrap-up • A tester’s goal is to eliminate faults as early as possible • Testing Improves software quality Reduce cost Preserve customer satisfaction • What’s next? • Fault, error, failure • Reachability, Infection, Propagation, and Revealability (RIPR) model Fall 2020 – University of Virginia © Praphamontripong 23