Programming Types of Testing.

Slides:



Advertisements
Similar presentations
GCSE Computing Lesson 5.
Advertisements

compilers and interpreters
16/13/2015 3:30 AM6/13/2015 3:30 AM6/13/2015 3:30 AMIntroduction to Software Development What is a computer? A computer system contains: Central Processing.
1 Lecture 1  Getting ready to program  Hardware Model  Software Model  Programming Languages  The C Language  Software Engineering  Programming.
Program Flow Charting How to tackle the beginning stage a program design.
Compilers and Interpreters. Translation to machine language Every high level language needs to be translated to machine code There are different ways.
1.3 Executing Programs. How is Computer Code Transformed into an Executable? Interpreters Compilers Hybrid systems.
Chapter 1: Introduction To Computer | SCP1103 Programming Technique C | Jumail, FSKSM, UTM, 2005 | Last Updated: July 2005 Slide 1 Introduction To Computers.
Activity 1 - WBs 5 mins Go online and spend a moment trying to find out the difference between: HIGH LEVEL programming languages and LOW LEVEL programming.
1 I.Introduction to Algorithm and Programming Algoritma dan Pemrograman – Teknik Informatika UK Petra 2009.
Computer Programming-1 CSC 111 Chapter 1 : Introduction.
CCSA 221 Programming in C CHAPTER 2 SOME FUNDAMENTALS 1 ALHANOUF ALAMR.
CHAPTER 4: INTRODUCTION TO COMPUTER ORGANIZATION AND PROGRAMMING DESIGN Lec. Ghader Kurdi.
Introduction 01_intro.ppt
P51UST: Unix and Software Tools Unix and Software Tools (P51UST) Compilers, Interpreters and Debuggers Ruibin Bai (Room AB326) Division of Computer Science.
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
© Janice Regan, CMPT 128, Jan CMPT 128 Introduction to Computing Science for Engineering Students Creating a program.
Simple Program Design Third Edition A Step-by-Step Approach
สาขาวิชาเทคโนโลยี สารสนเทศ คณะเทคโนโลยีสารสนเทศ และการสื่อสาร.
Programming Translators.
High level & Low level language High level programming languages are more structured, are closer to spoken language and are more intuitive than low level.
General Computer Science for Engineers CISC 106 Lecture 02 Dr. John Cavazos Computer and Information Sciences 09/03/2010.
PROGRAMMING LANGUAGES Prof. Lani Cantonjos. PROGRAM - set of step-by-step instructions that tells or directs the computer what to do. PROGRAMMING LANGUAGE.
Program Development Life Cycle (PDLC)
Programming With C.
Chapter 3 Developing an algorithm. Objectives To introduce methods of analysing a problem and developing a solution To develop simple algorithms using.
Testing Methods Carl Smith National Certificate Year 2 – Unit 4.
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
Unit-1 Introduction Prepared by: Prof. Harish I Rathod
Software Engineering Chapter 3 CPSC Pascal Brent M. Dingle Texas A&M University.
Chapter 1 Introduction Chapter 1 Introduction 1 st Semester 2015 CSC 1101 Computer Programming-1.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
CHAPTER 1 INTRODUCTION 1 st Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
1 Program Planning and Design Important stages before actual program is written.
CHAPTER 1 INTRODUCTION 2 nd Semester H King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1.
Introduction to OOP CPS235: Introduction.
Computer and Programming. Computer Basics: Outline Hardware and Memory Programs Programming Languages and Compilers.
Chapter 1: Introduction to Visual Basic.NET: Background and Perspective Visual Basic.NET Programming: From Problem Analysis to Program Design.
Chapter 11  Getting ready to program  Hardware Model  Software Model  Programming Languages  Facts about C++  Program Development Process  The Hello-world.
1 Asstt. Prof Navjot Kaur Computer Dept PRESENTED BY.
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
Introduction to Computer Programming using Fortran 77.
OCR A Level F453: The function and purpose of translators Translators a. describe the need for, and use of, translators to convert source code.
Programming 2 Intro to Java Machine code Assembly languages Fortran Basic Pascal Scheme CC++ Java LISP Smalltalk Smalltalk-80.
Introduction to Computer Programming Concepts M. Uyguroğlu R. Uyguroğlu.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Chapter 6 Testing and running a solution. Errors X Three types Syntax Logic Run-time.
Software Engineering Algorithms, Compilers, & Lifecycle.
Introduction to computer software. Programming the computer Program, is a sequence of instructions, written to perform a specified task on a computer.
Chapter 1 Introduction 2nd Semester H
Topic 2: Hardware and Software
Component 1.6.
Visit for more Learning Resources
CSC201: Computer Programming
CSCI-235 Micro-Computer Applications
Lecture 1: Introduction to JAVA
Translators & Facilities of Languages
Program Design Introduction to Computer Programming By:
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
CMP 131 Introduction to Computer Programming
Programming Fundamentals Lecture #3 Overview of Computer Programming
King Saud University College Of Applied Studies and Community Services CSC 1101 Computer Programming-1 Done By: Asmal Alosaimi Edited By: Fatimah Alakeel.
Programming Fundamentals (750113) Ch1. Problem Solving
PROGRAMMING FUNDAMENTALS Lecture # 03. Programming Language A Programming language used to write computer programs. Its mean of communication between.
Lecture 8 Programming Paradigm & Languages. Programming Languages The process of telling the computer what to do Also known as coding.
Programming Fundamentals (750113) Ch1. Problem Solving
Chapter 1 Introduction to Programming
WJEC GCSE Computer Science
CHAPTER 6 Testing and Debugging.
Presentation transcript:

Programming Types of Testing

Lesson Objectives Review and understand the concept of testing and debugging a program. Review the concept of a dry run test. Understand the concept of a trace table. Perform try run tests using trace tables.

Test and debug the program Testing is performed by a tester or end user to find bugs, faults or error in the program. The tester reports to the programmer or program development team.

Types of Testing There are two types of testing: A dry –run test involves applying test data to the program manually and tracing the logic or reasoning of the program using test data that will test each section of the program. This can even be done before the algorithm is translated into the programming language.

Types of testing Computer testing Compile the program. A computer can only execute a program written in machine language. Before the computer can run the Pascal program, the latter must be converted to machine language. The source code must be converted into machine language. The program which does this is a compiler. The compiler will check for errors in the program. e.g syntax errors

Types of testing What are some types of syntax errors in Lazarus? Omitting ; , ‘ () i.e. any violation of syntax rules

Types of testing Run the program. The user requests the computer to execute the program and the user supplies data to the program for which he or she knows the answer. Such data is called test data. If the program does not give the correct answers the user knows that the program has at least one logic error. If the program contains logic errors we must debug the program; find and correct those errors.

Types of testing Debugging is the process of fixing the errors found by the testers. NB Debugging is done by the programmer to fix the errors during the debugging phase.

Question Distinguish between testing and debugging. (2mks)

Answer Testing is performed by a tester or end user to find bugs, faults or error in the program. The tester reports to the programmer or program development team. However, Debugging is the process of fixing the errors found by the testers. Debugging is done by the programmer to fix the errors during the debugging phase.

Types of testing What type(s) of testing have we been doing so far?

Dry Run Testing Dry-running or desk checking or tracing involves executing the program manually by using input values for variables and recording what takes place after each instruction is executed. Tracing is a technique that allows the user to detect any logic errors in the program or algorithm.

Trace Tables A trace table is a table that is completed by tracing the instruction of the algorithm with given data to arrive at solutions. In designing the table, draw a column for each variable used in the algorithm and draw enough rows to form the cells to store the values. There should also be a heading ‘Output’ to record what is printed.

Trace Tables Choose simple input test data which is valid. Two or three sets of data is valid. Establish what the expected results should be for each teat case. This is do a manual solution beforehand. Create a trace table of all the variables in the algorithm. Walk the first test case through the algorithm, keeping a step by step record of the contents of each variable in the table as the data passes through the logic until the algorithm reaches its logical end. Check that the expected result established in step two matches the actual result developed in step 4 Repeat the process using a different set of data.

Example Super six is the name of the junior cricket team. The coach of super six has hired you to design a program to provide him with statistics after each match. Design an algorithm that reads a list consisting of the number of runs scored by each batsman in the team. There are six batsmen in the team. Compute and print the average number of runs scored by the team. Solution

Computer Testing Computer testing involves running the program using test data to discover any errors in the program.

Computer Testing Computer testing involves the following steps: Compile the program. A computer can only execute a program written in machine language. Before the computer can run the Pascal program, the latter must be converted to machine language. The source code must be converted into machine language. The program which does this is a compiler. The compiler will check for errors in the program .e.g. syntax errors

Computer Testing Run the program. The user requests the computer to execute the program and the user supplies data to the program for which he or she knows the answer. Such data is called test data. f the program does not give the correct answers the user knows that the program has at least one logic error. If the program contains logic errors we must debug the program; find and correct those errors.

Computer Testing The first step in computer testing is translating the high level program into machine code. The program written in the specific programming language is called the source code. The source code is translated into object code by the compiler. Programmers write programs in a form called source code. The source code consists of instructions in a particular language, like C or FORTRAN. Computers, however, can only execute instructions written in a low-level language called machine language.

Computer Testing To get from source code to machine language, the programs must be transformed by a compiler. The compiler produces an intermediary form called object code. Object code is often the same as or similar to a computer's machine language. The final step in producing an executable program is to transform the object code into machine language, if it is not already in this form. This can be done by a number of different types of programs, called assemblers, linkers, and loaders.

Computer Testing Converting a program to machine language is performed by a translator program. These are programs that translate a specific program from a high level language to machine language that the computer can understand. Interpreters, compilers and assemblers are all translators.

Interpreter An interpreter translates the source program line by line and if an error is detected then translation is aborted. If no errors are detected the interpreter instructs the control unit to execute the translated instruction. This cycle is repeated for each instruction. Therefore the interpreter translates one instruction at a time while the program is being executed. Translated codes are not saved; therefore each time the program is executed, translation is necessary.

Interpreter Advantages It translates one instruction at a time; therefore it uses a minimum amount of memory. It is also helpful in the debugging process because the interpreter can relate error messages to the instruction being executed Disadvantage Each time the program is executed time is spent interpreting, hence a slower execution time.

Compiler A compiler translates all program instructions at one time and produces machine language which can be executed. Error checks are performed and an error summary is used. This is not done at run time. The translated codes are known as object codes and are saved as a file on a disk. The object code has an EXE file extension. It is then loaded or linked and executed. The object code is executed each time the program is run but the source code needs to be compiled only once.

Compiler Advantages EXE files execute faster than source codes. The object codes are saved and can be run at any time. Object codes are harder for a user to change than source codes The compiler checks the source code for syntax errors during compilation Disadvantages As the entire program is translated it uses much more of the computer’s memory.

Assembler The assembler translates mnemonic type instruction to machine code. It translates low-level languages to machine language. The assembler program takes each program statement in the source program and generates a corresponding bit stream or pattern (a series of 0's and 1's).

Run the Program The second step in computer testing is to run the program. The user requests the computer to execute the program. The two terms commonly used with program execution are linking and loading.

Linking A compiled object program is not executable by itself. It needs to be combined with other system modules to form an executable program. A linker also called a link editor and binder is a program that combines object modules to form an executable program. Linking combines various pieces of code and data together to form a single executable object than can be loaded in memory. Linking can be done at compile time at load time or at run time.

Loading Loading involves copying a program from the hard disk to main memory in order to put the program in a ready to run state.

Executing The Program Program execution is the process whereby the program is dispatched to the CPU. In many of the language compilers today, the process of compiling, linking and executing are transparent to the user. On some menu- driven systems the user selects compile from the menu and the program is compiled and linked from this single option. On other systems selecting ‘run’ results in the program being linked and executed.

Program Execution When the program is being executed or run the user supplies test data to discover any errors in the program. There are three types of errors: Syntax errors Logic errors Run-time errors

Syntax Errors Syntax errors are mistakes made by a non conformance to the grammatical rules of the programming language. For example if we forget to terminate an assignment statement with a semi- colon or if a reserved word was used incorrectly. Syntax errors stop the source code being converted to machine code. Syntax errors can be easily located and corrected as the compiler usually issues messages which identify the location of the errors.

Logic Error Logic errors occur due to out of sequence instructions, faulty comparisons and selections. For example in order to find the average of three numbers, the numbers must be entered and added before dividing by three. Dividing by three before entering the numbers would be a logic error. The program will usually compile. Compilation with logic errors does not generate any syntax errors or warning messages but when the program is run it produces the wrong results.

Runtime Error Run-time errors are errors that occur after the program has been tested and debugged. They occur during the execution and running of the program. They usually occur due to events such as division by zero or lack of memory for the computer to manipulate the data.