Dept of Computer Science University of Maryland College Park

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

COMPUTER PROGRAMMING I Essential Standard 5.02 Understand Breakpoint, Watch Window, and Try And Catch to Find Errors.
MAHDI OMAR JUNIT TUTORIAL. CONTENTS Installation of Junit Eclipse support for Junit Using Junit exercise JUnit options Questions Links and Literature.
MT311 Tutorial Li Tak Sing( 李德成 ). Uploading your work You need to upload your work for tutorials and assignments at the following site:
Cell phones off Name signs out – congrats Sean! CSE 116 Introduction to Computer Science for Majors II1.
Integrated Development Environments. Today We Will: Go over more advanced functionality of Eclipse. Break up into teams to work on presentation and final.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
Java Review 2 – Errors, Exceptions, Debugging Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 CSC/ECE 517 Fall 2010 Lec. 2 Overview of Eclipse Lectures 1.Overview 2.Installing and Running 3.Building and Running Java Classes 4.Debugging 5.Testing.
CIT 590 Debugging. Find a laptop Please take a moment to open up your laptop and open up Eclipse. If you do not have a laptop, please find a friend. If.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
Recitation 7 James Wei Professor Peck 2/28/2014. Covered in this Recitation LinkedList practice with JUnit testing Submit through ambient.
Debugging Dwight Deugo Nesa Matic
Debugging. 2 © 2003, Espirity Inc. Module Road Map 1.Eclipse Debugging  Debug Perspective  Debug Session  Breakpoint  Debug Views  Breakpoint Types.
Debugging in Java. Common Bugs Compilation or syntactical errors are the first that you will encounter and the easiest to debug They are usually the result.
Testing and Debugging Version 1.0. All kinds of things can go wrong when you are developing a program. The compiler discovers syntax errors in your code.
(1) Unit Testing and Test Planning CS2110: SW Development Methods These slides design for use in lab. They supplement more complete slides used in lecture.
Unit Testing with JUnit and Clover Based on material from: Daniel Amyot JUnit Web site.
1 Debugging and Syntax Errors in C++. 2 Debugging – a process of finding and fixing bugs (errors or mistakes) in a computer program.
Week 14 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Copyright © 2004 – 2013 Curt Hill Java Debugging In Eclipse.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 4 Slide 1 Slide 1 What we'll cover here l Using the debugger: Starting the debugger Setting.
Georgia Institute of Technology Creating Classes part 2 Barb Ericson Georgia Institute of Technology June 2006.
Defensive Programming. Good programming practices that protect you from your own programming mistakes, as well as those of others – Assertions – Parameter.
Today protected access modifier Using the debugger in Eclipse JUnit testing TDD Winter 2016CMPE212 - Prof. McLeod1.
Debugging and Testing Hussein Suleman March 2007 UCT Department of Computer Science Computer Science 1015F.
Testing and Debugging UCT Department of Computer Science Computer Science 1015F Hussein Suleman March 2009.
Dept of Computer Science University of Maryland College Park
Conditionals, Block Statements, Style
DEBUG.
Debugging with Eclipse
Appendix A Barb Ericson Georgia Institute of Technology May 2006
Dept of Computer Science University of Maryland College Park
String Comparison, Scanner
Testing Tutorial 7.
Computer Organization, Eclipse Intro
Appendix A Barb Ericson Georgia Institute of Technology May 2006
Introduction to JUnit CS 4501 / 6501 Software Testing
Dept of Computer Science University of Maryland College Park
Debugging Dwight Deugo
Testing and Debugging.
Computer Programming I
Debugging CMSC 202.
Computer Science 209 Testing With JUnit.
Testing Key Revision Points.
Switch, Rounding Errors, Libraries
COS 260 DAY 17 Tony Gauvin.
Software Engineering 1, CS 355 Unit Testing with JUnit
Important terms Black-box testing White-box testing Regression testing
DEBUGGING.
Important terms Black-box testing White-box testing Regression testing
Overview of Eclipse Lectures
Debugging with Eclipse
COS 260 DAY 16 Tony Gauvin.
Comp 110/401 Appendix: Debugging Using Eclipse
Introduction to JUnit CS 4501 / 6501 Software Testing
DEBUGGING JAVA PROGRAMS USING ECLIPSE DEBUGGER
COMPUTER 2430 Object Oriented Programming and Data Structures I
Chapter 15 Debugging.
Testing, debugging, and using support libraries
Algorithm and Ambiguity
Our Environment We will exercise on Microsoft Visual C++ v.6
IDE’s and Debugging.
Debugging Dwight Deugo
An Introduction to Debugging
Java IDE Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from.
CMPE212 – Reminders Assignment 2 due today, 7pm.
Debugging with Eclipse
Workshop for Programming And Systems Management Teachers
Chapter 15 Debugging.
Presentation transcript:

Dept of Computer Science University of Maryland College Park CMSC 131 Object-Oriented Programming I Testing/Debugging Dept of Computer Science University of Maryland College Park This material is based on material provided by Ben Bederson, Bonnie Dorr, Fawzi Emad, David Mount, Jan Plane

Announcement (Not Related to CMSC 131) Make sure you do not miss your advising appointment. There are thousands of students and if you miss your appointment you might not get the course you want Be aware of which day and time you register. Being late by one minute could translate on you missing the class/section you want Some advising information available at: http://www.cs.umd.edu/~nelson/advising/

Debugging Process of finding and fixing software errors After testing detects error Goal Determine cause of run-time & logic errors Correct errors (without introducing new errors) Similar to detective work Carefully inspect information in program Code Values of variables Program behavior It is a skill you need to develop After all, there is no such thing as the “Company TA” 

Debugging Approaches Classic Insert debugging statements Trace program control flow Display value of variables Modern IDE (integrated development environment) Interactive debugger

Interactive Debugger Capabilities Provides trace of program execution Shows location in code where error encountered Interactive program execution Single step through code Run to breakpoints Displays values of variables For current state of program

Terminology Break Point Drop a marker into the code so when it runs the execution will stop at that point Allows you to not have to go step by step through things you believe are correct Step Over Takes one step in the current method If that step is a method call, it performs that whole method call and steps to the next line in the current method Step Into If that step is a method call, it steps into that method so that you can then step through it before getting to the next line in the method you were in

Eclipse Perspective Debug Perspective Java Perspective Run Debug As… Run As… Know if it is still running Watch the red square – click it to stop it Example: AuxMath.java Let’s set a break point in maximum Let’s see the contents of parameters Let’s see the different stack entries Let’s step over and step into

Testing JUnit  Testing framework for Java With JUnit testing you define a class where each method represents a tests To create the test method define public void methods that have the @Test annotation @Test public void checkingEvenValues() { …. } 110 % bullet list

JUnit Inside of a test method you can have typical Java code where assertions are used to specify the expected results for the test Common assertions: assertTrue → verifies that the argument expression is true. If the argument expression is false the test fails; otherwise execution is successful assertEquals → takes two arguments (expected value and actual value). If the values are not equal the test fails; otherwise execution is successful Example: JUnitExample.java You can define auxiliary methods (e.g. private methods) that support the set of tests you are developing You can have multiple assertions in a JUnit test. Once the first one fails the whole test is considered to had failed Pick descriptive names for your test methods 110 % bullet list

JUnit To create a JUnit .java test file in Eclipse: File→New→JUnit Test Case→New JUnit 4 test If the JUnit library is not part of the project you will get a message indicating whether it should be added; just add it Pick a class name (e.g., Myclass or any name you prefer) If you don't provide an assertion a test is not considered to fail The use of static fields can lead to results from one test to propagate to the next You can use the Eclipse debugger with JUnit tests You can add output statements to see results generated by your tests Helpful to identify problems with project tests Additional information at: http://www.cs.umd.edu/eclipse/test.html 110 % bullet list