Bugs & Debugging - Testing

Slides:



Advertisements
Similar presentations
Topics Introduction Types of Errors Exceptions Exception Handling
Advertisements

© The McGraw-Hill Companies, 2006 Chapter 15. © The McGraw-Hill Companies, 2006 Exceptions an exception is an event that occurs during the life of a program.
Exception Handling Chapter 12.  Errors- the various bugs, blunders, typos and other problems that stop a program from running successfully  Natural.
Exceptions and Exception Handling Carl Alphonce CSE116.
Exceptions Three categories of errors: Syntax errors Runtime errors Logic errors Syntax errors: rules of the language have not been followed. Runtime error:
Exceptions in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 Exception Handling (in a nutshell). 2 Motivations When a program runs into a runtime error, the program terminates abnormally. How can you handle the.
Introduction to Java Chapter 11 Error Handling. Motivations When a program runs into a runtime error, the program terminates abnormally. How can you handle.
Chapter 12: Exception Handling
Slides Credit Umair Javed LUMS Web Application Development.
Computer Programming 2 Lab(1) I.Fatimah Alzahrani.
2_Testing Testing techniques. Testing Crucial stage in the software development process. Significant portion of your time on testing for each programming.
Exceptions in Java. Exceptions An exception is an object describing an unusual or erroneous situation Exceptions are thrown by a program, and may be caught.
Chapter 3 Syntax, Errors, and Debugging Fundamentals of Java.
School of Computer Science & Information Technology G6DICP - Lecture 6 Errors, bugs and debugging.
ERRORS. Types of errors: Syntax errors Logical errors.
Exceptions and Assertions Chapter 15 – CSCI 1302.
PROGRAM ESSENTIALS. TOKENS  SMALLEST UNITS OF A PROGRAM LANGUAGE  Special Symbols  Mathematical Operators  Punctuation  Word Symbols  Key Words.
Error Handling Tonga Institute of Higher Education.
Programming & Debugging. Key Programming Issues Modularity Modifiability Ease of Use Fail-safe programming Style Debugging.
1 Exceptions. 2 Syntax Errors, Runtime Errors, and Logic Errors syntax errors, runtime errors, and logic errors You learned that there are three categories.
(c) University of Washington10-1 CSC 143 Java Errors and Exceptions Reading: Ch. 15.
Exceptions Lecture 11 COMP 401, Fall /25/2014.
Lecture10 Exception Handling Jaeki Song. Introduction Categories of errors –Compilation error The rules of language have not been followed –Runtime error.
Eighth Lecture Exception Handling in Java
Appendix H Exception Handling: A Deeper Look
The eclipse IDE IDE = “Integrated Development Environment”
Java Exceptions a quick review….
Introduction to Computing Science and Programming I
Lecture 2 D&D Chapter 2 & Intro to Eclipse IDE Date.
Testing Tutorial 7.
Exceptions In this lecture:
CS170 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
Tirgul 13 Exceptions 1.
Chapter 13 Exception Handling
Chapter 8 – Software Testing
Testing and Debugging.
2_Testing Testing techniques.
Chapter 12 Exception Handling and Text IO
Exceptions 10-Nov-18.
Exception Handling Chapter 9.
Common C Programming Errors, GDB Debugging
Chapter 12 Exception Handling
Exception Handling and Reading / Writing Files
Tonga Institute of Higher Education
Web Design & Development Lecture 7
Coding Concepts (Standards and Testing)
Programming Errors Key Revision Points.
Chapter 15 Debugging.
Error Analysis Runtime Errors.
CSE 143 Java Exceptions 1/18/2019.
Chapter 13 Exception Handling
Exceptions 19-Feb-19.
elementary programming
Lecture 11 Objectives Learn what an exception is.
Exceptions 7-Apr-19.
Errors and Exceptions Error Errors are the wrongs that can make a program to go wrong. An error may produce an incorrect output or may terminate the execution.
Chapter 12 Exception Handling and Text IO Part 1
CSC 143 Java Errors and Exceptions.
Learning Intention I will learn about the different types of programming errors.
Exceptions 10-May-19.
Lecture 14: Testing Testing used to verify object behavior through designed test suites Can test Classes – “unit” testing Object interactions – “integration”
Review of Previous Lesson
Exceptions References: Jacquie Barker, Beginning Java Objects; Rick Mercer, Computing Fundamentals With Java; Wirfs-Brock et. al., Martin Fowler, OOPSLA.
Chapter 15 Debugging.
Java Basics Exception Handling.
Testing & Security Dr. X.
Java Programming: From Problem Analysis to Program Design, 4e
CHAPTER 6 Testing and Debugging.
Chapter 15 Debugging.
Presentation transcript:

Bugs & Debugging - Testing 10 Bugs & Debugging - Testing

Previously Design a program Javadoc Break the problem into smaller ones It may help to do it several times to reduce the problem enough Outlines Javadoc Industry standard for documenting Java code Create documentation in HML format Other format can be obtained Doxygen can be used to get documentation in C++, Java and other langugaes

Overview Types of Errors When errors appear Compiler Errors Run-time errors Fixing errors Testing - Find Errors

Types of Errors Syntax errors Code that does not conform to the syntax of the programming language Detected a compiling time // Declaring variables int iCounter = 0 int iValue; iValue = ++iCounter; 1 2 3 4 5

Types of Errors Semantic errors Mistakes in the logic of the code Legal language code but not what intended Appear when running the code Exceptions

When errors appear Compile-time errors Run-time errors Appear when the code is compiled Run-time errors Appear when the code is running Makes the code to behave different than expected Could take long time before effects are seen Logical errors are run-time errors Some languages try to reduce the risk of this errors, Java is one of them

Compiler Errors Eclipse will show them with a read circle and a cross Some information is provided The point of the error may not be where the error was introduced Unbalanced braces cannot be detected until the braces are closed – indexation helps to detect the point of the problem Previous error may create other errors, “spurious” errors

Let see some using Eclipse! Compiler Errors Let see some using Eclipse!

Run-time errors Java does not allow some code to avoid potential run-time errors float fCostProduct1 = 12.50; float fCostProduct2 = 30.10; int iTotal = fCostProduct1 + fCostProduct2; Potential run-time errors may be detected by Eclipse and are displayed with a yellow triangle with an exclamation mark You should investigate them Take the appropriate action to remove them

Run-time errors Cause: Lack of validation An example would be when expected a number and provided a string Remember the exercise to convert from Celsius to Fahrenheit the data is inputted as an string from the console and converted to a number What happen if the user input a character not a digit? An exception is thrown

Run-time errors RuntimeException ArithmeticException e.g. 10 / 0 NullPointerException IndexOutOfBoundsException ... See lecture 6 Exceptions s are a type of Throwable RuntimeExceptions are a type of Exception

Run-time errors Other causes: External factors Internal factors Out of memory Insufficient i/o privileges ... Internal factors Arithmetic errors Invalid operation, e.g. try to read beyond the end of a file Try to access an object that doesn’t exist, e.g. null object Attempt to read beyond the end of an array

Run-time errors Logical errors Causes a program to operate incorrectly The program does not terminate abnormally or crash The behaviour of the program is different that what was intended Can be difficult to spot

Run-time errors 1 2 3 4 5 6 7 8 9 10 11 12 // Example of a logical error String strAnswer; System.out.println("Press 'y' to continue or any other key” + ” to terminate: "); strAnswer = Scanner.nextLine(); // Exit the program if the key 'y' is pressed if (strAnswer.charAt(0) == 'n') { // Terminate the application System.exit(0); } ...

Let see some using Eclipse! Run-time errors Let see some using Eclipse!

Fixing errors Need to know an error exists – find errors Gather as much information as possible Logging messages helps Establish where the error happens in the code Debugging is the process of locating the errors (bugs) in the code Design the fix Implement the fix Test that the fix really fixes the problem

Let do some debugging using Eclipse! Run-time errors Let do some debugging using Eclipse!

Testing - Find Errors Test to find errors (bugs) that may exist in the code Different type of tests are conducted at different stages of a project Tests intend to establish the compliance to the requirements Errors should be reproducible! Requirement to be able to locate them and fix Information gathered required to reproduce it

Testing - Find Errors Create unit testing Run some simple examples Test units of your code Check if the unit does what it is expected The units are methods Use JUnit in Java Run some simple examples System test Test the complete, integrated system to evaluate the compliance of the system – behave as expected Customers – NOT GOOD