slide1 n.
Skip this Video
Loading SlideShow in 5 Seconds..
Bugs & Debugging - Testing PowerPoint Presentation
Download Presentation
Bugs & Debugging - Testing

Loading in 2 Seconds...

play fullscreen
1 / 19

Bugs & Debugging - Testing - PowerPoint PPT Presentation

  • Uploaded on

10. Bugs & Debugging - Testing. Previously. Design a program 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.

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

Bugs & Debugging - Testing

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript


Bugs & Debugging - Testing

  • Design a program
    • 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
  • Types of Errors
  • When errors appear
  • Compiler Errors
  • Run-time errors
  • Fixing errors
  • Testing - Find Errors
types of errors
Types of Errors
  • Syntax errors
    • Code that does not conform to the syntax of the programming language
    • Detected a compiling time

// Declaring variables

intiCounter = 0


iValue = ++iCounter;






types of errors1
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
When errors appear
  • Compile-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
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
compiler errors1
Compiler Errors

Let see some using Eclipse!

run time errors
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 errors1
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 errors2
Run-time errors


ArithmeticException e.g. 10 / 0




run time errors3
Run-time errors

Other causes:

  • External 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 errors4
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 errors5
Run-time errors













// 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




run time errors6
Run-time errors

Let see some using Eclipse!

fixing errors
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
run time errors7
Run-time errors

Let do some debugging using Eclipse!

testing find errors
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 errors1
Testing - Find Errors
  • Create unit testing
    • 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