1 CEN 4072 Software Testing PPT3: Making the program fail.

Slides:



Advertisements
Similar presentations
Introduction to .NET Framework
Advertisements

Tahir Nawaz Introduction to.NET Framework. .NET – What Is It? Software platform Language neutral In other words:.NET is not a language (Runtime and a.
Ch 3 System Development Environment
Software Engineering 2003 Jyrki Nummenmaa 1 OBJECT ARCHITECTURE DESIGN These slides continue with our example application, based on the simplified.
Java.  Java is an object-oriented programming language.  Java is important to us because Android programming uses Java.  However, Java is much more.
© by Pearson Education, Inc. All Rights Reserved.
CS-3013 & CS-502, Summer 2006 Virtual Machine Systems1 CS-502 Operating Systems Slides excerpted from Silbershatz, Ch. 2.
Automating Tasks With Macros
© 2005 Prentice Hall12-1 Stumpf and Teague Object-Oriented Systems Analysis and Design with UML.
Computers: Tools for an Information Age
Satzinger, Jackson, and Burd Object-Orieneted Analysis & Design
1 CS6320 – Why Servlets? L. Grewe 2 What is a Servlet? Servlets are Java programs that can be run dynamically from a Web Server Servlets are Java programs.
Chapter 1 Principles of Programming and Software Engineering.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment Chapter 8: Implementing and Managing Printers.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment Chapter 8: Implementing and Managing Printers.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Application Architectures Vijayan Sugumaran Department of DIS Oakland University.
Principle of Functional Verification Chapter 1~3 Presenter : Fu-Ching Yang.
Software Life Cycle Model
Tutorial -01. Objective In this session we will discuss about : 1.What is MVC? 2.Why MVC? 3.Advantages of MVC over ASP.NET 4.ASP.NET development models.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 18 Slide 1 Software Reuse 2.
Lesson 4 Computer Software
INTRODUCTION TO WEB DATABASE PROGRAMMING
A First Program Using C#
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 14Slide 1 Design with Reuse l Building software from reusable components.
Architecture Of ASP.NET. What is ASP?  Server-side scripting technology.  Files containing HTML and scripting code.  Access via HTTP requests.  Scripting.
ABSTRACT Zirous Inc. is a growing company and they need a new way to track who their employees working on various different projects. To solve the issue.
M Gallas CERN EP-SFT LCG-SPI: SW-Testing1 LCG-SPI: SW-Testing LCG Applications Area GridPP 7 th Collaboration Meeting LCG/SPI LCG.
ASP.NET + Ajax Jesper Tørresø ITNET2 F08. Ajax Ajax (Asynchronous JavaScript and XML) A group of interrelated web development techniques used for creating.
© 2012 IBM Corporation Rational Insight | Back to Basis Series Chao Zhang Unit Testing.
COMPUTER PROGRAMMING Source: Computing Concepts (the I-series) by Haag, Cummings, and Rhea, McGraw-Hill/Irwin, 2002.
Designing For Testability. Incorporate design features that facilitate testing Include features to: –Support test automation at all levels (unit, integration,
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Tracking The Problem  By Aaron Jackson. What’s a Problem?  A suspicious or unwanted behavior in a program  Not all problems are errors as some perceived.
Capture and Replay Often used for regression test development –Tool used to capture interactions with the system under test. –Inputs must be captured;
Computer Programming 12 Mr. Jean March 19 th, 2013.
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
Design and Programming Chapter 7 Applied Software Project Management, Stellman & Greene See also:
Chapter 34 Java Technology for Active Web Documents methods used to provide continuous Web updates to browser – Server push – Active documents.
CSC 211 Introduction to Design Patterns. Intro to the course Syllabus About the textbook – Read the introduction and Chapter 1 Good attendance is the.
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Architectural Styles.
Extreme/Agile Programming Prabhaker Mateti. ACK These slides are collected from many authors along with a few of mine. Many thanks to all these authors.
(c) University of Washington08-1 CSC 143 Models and Views Reading: Ch. 18.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
C H A P T E R T E N Event-Driven Programming Programming Languages – Principles and Paradigms by Allen Tucker, Robert Noonan.
Software Development Process.  You should already know that any computer system is made up of hardware and software.  The term hardware is fairly easy.
CE Operating Systems Lecture 3 Overview of OS functions and structure.
Intermediate 2 Software Development Process. Software You should already know that any computer system is made up of hardware and software. The term hardware.
Module 4 Part 2 Introduction To Software Development : Programming & Languages Introduction To Software Development : Programming & Languages.
CIS 112 Exam Review. Exam Content 100 questions valued at 1 point each 100 questions valued at 1 point each 100 points total 100 points total 10 each.
I Power Higher Computing Software Development Development Languages and Environments.
Making Your Program Fail CEN Before the Bugs  Why would a software development team release their work with known bugs? They wouldn’t; they would.
Making the Program Fail CEN4072 – Software Testing – PPT3 Charles Powell.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Getting Started with.NET Getting Started with.NET/Lesson 1/Slide 1 of 31 Objectives In this lesson, you will learn to: *Identify the components of the.NET.
MVC WITH CODEIGNITER Presented By Bhanu Priya.
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
JavaScript Introduction and Background. 2 Web languages Three formal languages HTML JavaScript CSS Three different tasks Document description Client-side.
Testing JUnit Testing. Testing Testing can mean many different things It certainly includes running a completed program with various inputs It also includes.
OCR A Level F453: The function and purpose of translators Translators a. describe the need for, and use of, translators to convert source code.
OPERATING SYSTEMS (OS) By the end of this lesson you will be able to explain: 1. What an OS is 2. The relationship between the OS & application programs.
Lesson 2: First Java Programs. 2.1 Why Java? Java is one of the most popular programming languages in the world. Java is a modern object-oriented programming.
PROGRAMMING (1) LECTURE # 1 Programming and Languages: Telling the Computer What to Do.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Module 01 ETICS Overview ETICS Online Tutorials
Software models - Software Architecture Design Patterns
Chapter 7 –Implementation Issues
Java Programming Introduction
Designing For Testability
Presentation transcript:

1 CEN 4072 Software Testing PPT3: Making the program fail

Two views of testing TESTING FOR VALIDATION Testing for unknown failures Goal is to uncover as many problems as possible TESTING FOR DEBUGGING Testing for known failures Goal is to reproduce a specific problem Used in many stages of debugging 2

Tests in debugging Tests are used for many stages in debugging. They are used for the following reasons: 1. To reproduce the problem 2. To simplify the problem 3. To observe the run 4. To verify successful fixes (Validation) 5. To ensure before each new release that similar problems will not occur in the future. (Known as Regression Testing) 3

Make the code fail There are several tests that can isolate failure causes automatically: 1. Failure-inducing input 2. Failure-inducing code changes 3. Failure-inducing thread schedules 4. Failure-inducing states (These are defined in depth in chapters 13 and 14) 4

Challenges of making the program fail When simulating program failures there are a few concepts to consider: 1. Synchronization: The simulation must follow the steps that cause the program to crash in exactly the same order that caused the crash the first time in order to monitor the outputs at every step. 2. Abstraction: There are different levels of abstraction that can be simulated in order to narrow down the possible causes of the failures. The higher the abstraction level, the easier it is to simulate interaction, however; this risks abstracting away the details that caused the failure. 3. Portability: Many programs have high portability, meaning they can run in a wide variety of environments. Some failures occur in some environments and not others, in which case, the tester must reproduce the same environment in order to reproduce the same failure. The goal is to fix all failures for all potential environments. 5

Interaction layers Programs can be broken down into three layers for testing: 1. Presentation layer: Handles the interaction with the user or the environment of the program. 2. Functionality layer: Includes only the functionality of the program. 3. Unit layer: Splits the functionality across multiple units that cooperate to produce a greater whole. 6

Presentation layer Low level: At the lowest abstraction level, user input can be captured and replayed as a stream of mouse and keyboard events. This can be recorded as a script, which includes exactly the input produced by the user and the time between each event. This makes it possible to simulate the user input in the exact way that initially caused the problem. System level: At the system level the goal is to simulate the hardware of a real machine using virtual machines in order to simulate things such as hardware defects. The scripts control the hardware directly. High level: At higher abstraction levels, the application is controlled using graphical user controls which are accessed via the script. 7

8 Low level interaction script Mouse and keyboard events

9 System level interaction script Simulating hardware, notice the HDL style syntax

10 Higher level interaction script Commands replace events normally controlled by the User Interface.

Scripting languages VBSCRIPT (Visual Basic Script): Scripting language widely used for Windows and Internet Explorer. PERL: General purpose scripting language. Runs on over 100 platforms and is “suitable for rapid prototyping and large scale development projects.” PYTHON: General purpose scripting language similar to PERL except that it emphasizes data structure design and object-oriented design over common application-oriented tasks. APPLESCRIPT: Scripting language widely used for Macintosh as well as Safari and Mozilla web browsers. 11

Functionality layer Programs may provide an interface that is designed for automation. They are generally designed for interaction with technical systems such as programming languages or scripting languages. For example an APPLESCRIPT program that uses scripting capabilities on the Safari web browser which uses such commands as: “set the URL of the front document”. This command works regardless of the user interface and is unaffected by changes to the user interface. Not every feature of Safari is scriptable in this way (ex: the print function) therefore; some functions still require testing at the presentation layer. The advantage of testing at the functionality layer is that the results can be easily accessed and evaluated. The difficulty with testing at the functionality layer is that it requires separation between the functionality and presentation layers, which is not always available, especially in older programs. 12

Unit tests Programs can be broken down into many units such as subprograms, functions, libraries, modules, classes, objects etc. depending on the programming language used. Unit tests are designed to execute just one of these units at a time rather than the program as a whole. A suite is commonly set up to run multiple unit tests at once and a main function is commonly included to run the tests and get the results. 13

Running unit tests Testing frameworks can be used to collect data from a number of individual unit tests automatically. When a single unit test executes the framework does three things: 1.Sets up an environment with only what is needed for the unit to execute. This may include other units the unit must interact with. 2.Tests the unit using enough test cases to cover every possible behavior of the unit, verifying that the results are as expected. 3.Closes the environment and goes back to the state that was initially encountered. 14

Unit test with JUNIT (JUNIT is a unit test framework in Java) Set up 3. Close 2. Tests To Run The “URLTest” class is a subclass of “TestCase”

Unit test with JUNIT (continued) 16 Set up a suite that runs all tests Main method starts JUNIT graphical Interface.

Unit test with PyUnit PyUnit is a unit test framework in Python. This example was found at: m/2011/11/getting-started- with-python-unit-testing- pyunit/ Notice that it includes the same basic principles as the JUNIT test. 17 Set up Close Tests to run Can add tests to a suite to run multiple tests Main function

Breaking circular dependenc y As shown in Example 3.11 the print_to_file function calls the confirm_loss function to first ask the user if overwriting is ok. Some programs have functionality that depends on presentation. To illustrate this the following is an example of this in which a function to print a web page to a file is called that asks the user if they want to overwrite the file if it already exists. 18 Circular dependence:

Breaking circular dependenc y (Continued) As shown in Figure 3.4 The presentation (user prints) invokes print_to_file which is part of the core functionality. The functionality (print function runs) invokes confirm_loss which is part of the user presentation. The consequence of circular dependence is that the presentation and functionality can’t be separated, which makes testing more difficult. 19 Circular dependence (continued):

Breaking circular dependenc y (continued) A good solution to this is to use inheritance to make the presentation an interface, or more specifically; an abstract super class that is instantiated in subclasses. In the previous case, we could make an automated presentation subclass that includes a confirm_loss function that automatically returns true, breaking the dependence on the user/presentation. 20

Design for debugging The main concept of designing for debugging is to reduce the number of dependencies by depending on abstractions rather than details. The goal is to separate as many dependencies as possible. This includes presentation and functionality at the application level as shown in the previous example. Remember that to do this we used inheritance to create a super class with subclasses that offer alternative automated versions of functions. One of the most popular examples of this technique is the model-view- controller architecture pattern shown in the next couple slides. 21

Model-View-Controller (MVC) The Model-View-Controller includes: 1.A model that holds and operates on core data. 2.A number of observers that register or attach to the model to get notified whenever core data changes. The observers are then divided into two subclasses: 1.A view class responsible for displaying the core data in any way needed. 2.A controller class to handle inputs and invokes the services of the model. 22

MVC (Continued) 23 The Model-View-Controller shown in figure 3.7 is quite beneficial for testing and debugging. Controllers can be added to automate execution of the services provided in the model. Thus avoiding dependencies between presentation and functionality by bypassing the need for user interaction.

General design rules High cohesion: The principle of grouping together parts of a system that work on common data into a single unit. For example object-oriented design groups data and functions into classes. Low coupling: The principle of reducing dependences. If two units do not operate on the same data, then they should exchange as little information as possible. For example the confirm_loss function from the previous slides would violate this principle by coupling presentation and functionality more than necessary. 24

Tools for automated testing JUNIT: Unit test tools ANDROID: A scripting language no longer available for download APPLESCRIPTS: Apple scripting language VBSCRIPT: Visual Basic scripting language FAUMachine: Virtual machines publically available which allows you to control the entire virtual machine via script. Virtual PC: Microsoft Virtual PC for various operating systems

References unit-testing-pyunit/ unit-testing-pyunit/ Zeller, A. (2009). Why Programs Fail: A Guide to Systematic Debugging. (2 nd ed.). Burlington, MA: Morgan Kauffman Publishers. 26