IMPORTANT NOTICE TO STUDENTS:

Slides:



Advertisements
Similar presentations
Chapter 14 Software Testing Techniques - Testing fundamentals - White-box testing - Black-box testing - Object-oriented testing methods (Source: Pressman,
Advertisements

Unit-V testing strategies and tactics.
System Integration Verification and Validation
SOFTWARE TESTING. INTRODUCTION  Software Testing is the process of executing a program or system with the intent of finding errors.  It involves any.
CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
Illinois Institute of Technology
Testing an individual module
1 Software Testing Techniques CIS 375 Bruce R. Maxim UM-Dearborn.
Software Testing Verification and validation planning Software inspections Software Inspection vs. Testing Automated static analysis Cleanroom software.
Testing. Definition From the dictionary- the means by which the presence, quality, or genuineness of anything is determined; a means of trial. For software.
University of Palestine software engineering department Testing of Software Systems Fundamentals of testing instructor: Tasneem Darwish.
Objectives Understand the basic concepts and definitions relating to testing, like error, fault, failure, test case, test suite, test harness. Explore.
CS 501: Software Engineering Fall 1999 Lecture 16 Verification and Validation.
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.
Software Reviews & testing Software Reviews & testing An Overview.
Software Testing The process of operating a system or component under specified conditions, observing and recording the results, and making an evaluation.
Agenda Introduction Overview of White-box testing Basis path testing
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 22 Slide 1 Software Verification, Validation and Testing.
Software Testing Reference: Software Engineering, Ian Sommerville, 6 th edition, Chapter 20.
1 Ch. 1: Software Development (Read) 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 20 Slide 1 Defect testing l Testing programs to establish the presence of system defects.
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
CS 360 Lecture 16.  For a software system to be reliable:  Each stage of development must be done well, with incremental verification and testing. 
Software Testing and Quality Assurance 1. What is the objectives of Software Testing?
CS451 Lecture 10: Software Testing Yugi Lee STB #555 (816)
Theory and Practice of Software Testing
1 Software Testing Strategies: Approaches, Issues, Testing Tools.
SOFTWARE TESTING. Introduction Software Testing is the process of executing a program or system with the intent of finding errors. It involves any activity.
Software Quality Assurance and Testing Fazal Rehman Shamil.
HNDIT23082 Lecture 09:Software Testing. Validations and Verification Validation and verification ( V & V ) is the name given to the checking and analysis.
CS223: Software Engineering Lecture 21: Unit Testing Metric.
Software Testing Reference: Software Engineering, Ian Sommerville, 6 th edition, Chapter 20.
SOFTWARE TESTING. SOFTWARE Software is not the collection of programs but also all associated documentation and configuration data which is need to make.
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
Defect testing Testing programs to establish the presence of system defects.
1 Software Testing. 2 What is Software Testing ? Testing is a verification and validation activity that is performed by executing program code.
Software Testing CS 560. Software testing strategies A strategic approach to testing  Functionality meets the requirements that guided its design. 
Based on slides created by Ian Sommerville & Gary Kimura
PREPARED BY G.VIJAYA KUMAR ASST.PROFESSOR
Software Testing Strategies for building test group
Software Testing.
SOFTWARE TESTING Date: 29-Dec-2016 By: Ram Karthick.
Group mambers: Maira Naseer (BCS ).
Software Engineering (CSI 321)
Software Testing.
Software Testing.
Software Engineering (CSI 321)
Software Testing An Introduction.
Chapter 8 – Software Testing
Some Simple Definitions for Testing
Types of Testing Visit to more Learning Resources.
Software testing strategies 1
Software testing strategies 2
Introduction to Software Testing
Software Testing (Lecture 11-a)
Chapter 14 Software Testing Techniques
Lecture 09:Software Testing
Introduction to Systems Analysis and Design
CS240: Advanced Programming Concepts
Chapter 10 – 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.
Software Verification, Validation, and Acceptance Testing
Software Testing “If you can’t test it, you can’t design it”
Case Study 1 By : Shweta Agarwal Nikhil Walecha Amit Goyal
Test Cases, Test Suites and Test Case management systems
Chapter 7 Software Testing.
Software Testing Strategies
Presentation transcript:

IMPORTANT NOTICE TO STUDENTS: These slides are NOT to be used as a replacement for student notes. These slides are sometimes vague and incomplete on purpose to spark class discussions. Software Unit Testing CS 360 Lecture 17

Model of the Software testing process (documentation)

General characteristics of software testing Development teams should conduct effective formal reviews (technical reviews, code reviews, integration/system testing, etc.) The objective is to arrive at a superior version of the product being reviewed. By correcting defects or developing new functionality Testing begins at the component level Make sure individual functions/interfaces of all components work correctly, then move toward integration testing of the entire system. Testing is conducted mostly by the development team. Testing and debugging are different activities Testing: “based on requirements, does function A do X?” Debugging: function A doesn’t work with function B because function A calls function B incorrectly. Correct the call for function B in function A.

Software Levels of Testing (documentation) Unit (Component) testing Concentrates on each implemented component/function of the software. Used to generate documentation of how each function works. Integration testing Focuses on the design and construction of the software architecture. Individual components are combined and tested as a group. System testing The software and other system elements are tested as a whole. System testing should require no knowledge of the system architecture or code. Validation testing Requirements (Functional/Non-Functional) are validated against the implemented software to make sure it meets stakeholder requirements. Acceptance/User Testing The software is tested by members outside of the development team

When is Testing Complete? There is no definitive answer to this question. Every time a user executes the software, the program is being tested. Sadly, testing usually stops when a project is running out of time, money, or both. System/Software testing is one of the most demanded abilities for new industry employees.

Unit Testing Focuses on generating test cases for: Functional correctness/completeness Internal program logic and data structures Optimizing algorithms and performance Error handling There is some debate about what constitutes a “unit”. Here some common definitions of a unit: A single class/method/function scope The smallest chunk that can be compiled by itself A single component scope (including interfaces)

Benefits of Unit Testing Improves the quality of code by identifying defects before integration. Provides documentation on all tested components. Allows the programmer/team to refactor code and make sure it still works correctly. Testing the smaller parts of a program before integration makes integration testing easier.

Unit Testing Techniques

Targets for Unit Test Cases (documentation) Component interfaces Local data structures Boundary conditions Independent paths (basis paths) Error handling paths

Static and dynamic testing Static testing: Testing techniques that does not include execution of the software. May be manual or use computer tools. Dynamic testing: Testing by executing the software with trial data. Debugging to remove errors.

Static testing - Reviews Form of static testing that is carried out throughout the software development process.

Project Team (Technical and Code) Review Goals Understanding the problem Project consistency Collective ownership of the code Code reuse Knowledge sharing in the team Improving the programmer! Error diagnosis Scheduling and management control

Static testing: Code Reviews Formal program reviews whose objectives are to verify functionality and detect faults Code is read and reviewed line by line. 150 to 250 lines of code in 2 hour meeting. Use checklist of common errors. Requires team commitment and face to face meetings.

Dynamic testing: Unit testing, Basis paths (documentation) The objective of path testing is to build a set of test cases so that each path through the program is executed at least once. Ensures statement/branch coverage. If every condition in a compound condition is considered: Condition coverage can be achieved as well. Steps for basis path testing: Draw a (control) flow graph using the source code. Line numbers can dictate each node in the graph. Calculate the cyclomatic complexity using the flow graph. Studies have shown: CC is directly related to the number of errors in the source code. CC of 10 is a practical upper limit for testing a single component. Determine the basis set of linearly independent paths. Design test cases to exercise each path in the basis set.

Dynamic testing: Unit testing, Basis paths (documentation) Flow Graphs Used to depict program control structure. Can be drawn from a piece of source code. Flow Graph Notation: composed of edges and nodes. An edge starts from one node and ends at another node.

Dynamic testing: Unit testing, Basis paths (documentation) Flow graph for extreme algorithm

Dynamic testing: Unit testing, Basis paths (documentation) Calculating cyclomatic complexity: E = number of edges N = number of nodes P = set of connected components CC = E – N + 2P CC = 11 – 10 + 2 = 3 Independent paths through the program: 12, 1, 2, 3, 5, 6, 7, 10 \\one element 12, 1, 2, 3, 5, 6, 7, 8, 7, 10\\max in 1st position 12, 1, 2, 3, 5, 6, 7, 8, 9, 7, 10\\searching for max Test cases should be derived so that all of these paths are executed

Dynamic testing: Unit testing, Basis paths (documentation) Designing the test cases: Path 1 test case: 12, 1, 2, 3, 5, 6, 7, 10 Input data: [4] Expected output: 4 Path 2 test case: 12, 1, 2, 3, 5, 6, 7, 8, 7, 10 Input data: [6, 2, 5, 1, 3] Expected output: 6 Path 3 test case: 12, 1, 2, 3, 5, 6, 7, 8, 9, 7, 10 Input data: [5, 2, 1, 1, 8, 3, 4] Expected output: 8

Dynamic testing: Unit testing, Basis paths Example 2 (documentation) Flow graph for Fibonacci algorithm

Dynamic testing: Unit testing, Basis paths Example 2 (documentation) Calculating cyclomatic complexity: CC = E – N + 2P CC = 13 – 12 + 2 = 3 Independent paths through the program: 1, 2, 3, 4, 7, 8, 9 \\ n == 0 1, 2, 3, 4, 7, 8, 9, 10, 15 \\ n == 1 1, 2, 3, 4, 7, 8, 9, 10, 11, 12, 13 \\ n > 1

Dynamic testing: Unit testing, Basis paths Example 2 (documentation) Designing the test cases: 0,1, 1, 2, 3, 5, 8, … Path 1 test case: 1, 2, 3, 4, 7, 8, 9 Input data: 0 Expected output: 0 Path 2 test case: 1, 2, 3, 4, 7, 8, 9, 10, 15 Input data: 1 Expected output: 1 Path 3 test case: 1, 2, 3, 4, 7, 8, 9, 10, 11, 12, 13 Input data: 2

Team Activity: Unit testing, Basis paths Generate the flow graph, calculate the cyclomatic complexity, and define the independent paths for the following program:

Documentation of testing (documentation) Every project needs a test plan that documents the testing procedures for completeness, visibility, and for future maintenance. It should include: Description of testing approach. List of test cases and related bugs. Procedures for running the tests. Test analysis report.

Unit Test Cases (documentation) Unit Test Plan Scope (In Scope – Out of Scope) In Scope Out of Scope In Scope List features/functions that are tested (numbered test cases).   Out of Scope List features/functions that are not tested.

Unit Test Cases (documentation) ID Test Cases Input Value Expected Output Pass/Fail Date Tested # Identify the test cases along with the expected results. mm/dd/yyyy 1 Example: Test Procedure: Login with a user account name and password. Username: abc Password: abc Expected Results: Successful user login. otherwise, an error will be displayed for the wrong credentials.   Id: abc Pw: abc Pw: abb Id: aba Successful login Username/Password doesn’t match Pass 11/08/2018

Guidelines for Unit Testing Unit tests should be fully automated. These tests should be executed often to verify correct functionality. Keep unit tests small and fast. Ideally, unit tests should be executed before every code check in. Small/fast tests reduce development turnaround time. Make unit tests easy to run. See guideline 1.

Guidelines for Unit Testing Analyze and fix failing unit tests and test cases immediately. Test developers are responsible for making sure a new unit tests run successfully before using them. If a test case fails, the entire team should move their focus to the problem to make sure it gets resolved. Keep unit tests independent. Test cases should never depend on other test cases, nor should they depend on the ordering in which they are executed. Name unit tests properly. Each unit test should verify the functionally of one distinct component feature. Typical naming convention: test[name], testAddUser, testDBConnection, etc.

Guidelines for Unit Testing Provide negative unit test cases. These tests intentionally misuse the code to verify robustness and appropriate error handling. Write unit test cases to reproduce errors. When an error is uncovered, isolate the test case to reproduce the error and use this test as a success criteria when fixing the code. Know unit testing limitations. Unit tests can never prove 100% correctness of code. Prioritize unit testing (and other types of testing). Understand the trade-off between the cost of writing test cases, and the cost of not writing test cases.