Testing and Debugging pt.2 Intro to Complexity CS221 – 2/18/09.

Slides:



Advertisements
Similar presentations
COMPUTER PROGRAMMING I Essential Standard 5.02 Understand Breakpoint, Watch Window, and Try And Catch to Find Errors.
Advertisements

Debugging What can debuggers do? Run programs Make the program stops on specified places or on specified conditions Give information about current variables’
{ Dominion - Test Plan Version 1 – 22 nd Apr Aravind Palanisami.
Computer science is a field of study that deals with solving a variety of problems by using computers. To solve a given problem by using computers, you.
Debugging Techniques1. 2 Introduction Bugs How to debug Using of debugger provided by the IDE Exception Handling Techniques.
CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
Time Complexity Intro to Searching CS221 – 2/20/09.
Testing and Debugging CS221 – 2/13/09. Airline Program.
CS 206 Introduction to Computer Science II 09 / 10 / 2008 Instructor: Michael Eckmann.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
CISC220 Spring 2010 James Atlas Lecture 06: Linked Lists (2), Big O Notation.
Data Structures Performance Analysis.
CS 206 Introduction to Computer Science II 09 / 05 / 2008 Instructor: Michael Eckmann.
Computer Science 2 Data Structures and Algorithms V section 2 Intro to “big o” Lists Professor: Evan Korth New York University 1.
CS 206 Introduction to Computer Science II 01 / 28 / 2009 Instructor: Michael Eckmann.
Analysis of Algorithm.
20 February Detailed Design Implementation. Software Engineering Elaborated Steps Concept Requirements Architecture Design Implementation Unit test Integration.
DEBUGGERS For CS302 Data Structures Course Slides prepared by TALHA OZ (most of the text is from
Computer Science 2 Data Structures and Algorithms V Intro to “big o” Lists Professor: Evan Korth New York University 1.
AlgoTutor Tutorial (3) Program Pad J. Yoo, S. Yoo, C. Pettey, S. Seo, and Z. Dong MTSU Computer Science Department Making the transition from the algorithm.
Test-Driven Development With Visual Studio 2005 Erno de Weerd Info Support.
Dr. Pedro Mejia Alvarez Software Testing Slide 1 Software Testing: Building Test Cases.
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
1 Debugging and Testing Overview Defensive Programming The goal is to prevent failures Debugging The goal is to find cause of failures and fix it Testing.
1 ENERGY 211 / CME 211 Lecture 13 October 20, 2008.
Chapter 12 Recursion, Complexity, and Searching and Sorting
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.
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
CSC 395 – Software Engineering Lecture 10: Execution-based Testing –or– We can make it better than it was. Better...faster...agiler.
Starting Out with C++ Early Objects Seventh Edition by Tony Gaddis, Judy Walters, and Godfrey Muganda Modified for use by MSU Dept. of Computer Science.
Slide 1 Project 1 Task 2 T&N3311 PJ1 Information & Communications Technology HD in Telecommunications and Networking Task 2 Briefing The Design of a Computer.
Debuggers in Python. The Debugger Every programming IDE has a tool called a debugger. This application does NOT locate or fix your bugs for you! It slows.
Week 14 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
Design - programming Cmpe 450 Fall Dynamic Analysis Software quality Design carefully from the start Simple and clean Fewer errors Finding errors.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Debugging COMP T1.
Unit - V. Debugging GNU Debugger helps you in getting information about the following: 1.If a core dump happened, then what statement or expression did.
Scalability for Search Scaling means how a system must grow if resources or work grows –Scalability is the ability of a system, network, or process, to.
Searching Topics Sequential Search Binary Search.
CISC220 Spring 2010 James Atlas Lecture 07: Big O Notation.
Higher Computing Science 2016 Prelim Revision. Topics to revise Computational Constructs parameter passing (value and reference, formal and actual) sub-programs/routines,
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel.
An introduction to the debugger And jGrasp editor-syncrasies (ideosyncrasies)
Today protected access modifier Using the debugger in Eclipse JUnit testing TDD Winter 2016CMPE212 - Prof. McLeod1.
Beginning Software Craftsmanship Brendan Enrick Steve Smith
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Debugging and Testing Hussein Suleman March 2007 UCT Department of Computer Science Computer Science 1015F.
Debuggers. Errors in Computer Code Errors in computer programs are commonly known as bugs. Three types of errors in computer programs –Syntax errors –Runtime.
Testing and Debugging UCT Department of Computer Science Computer Science 1015F Hussein Suleman March 2009.
Testing Tutorial 7.
C++ Plus Data Structures
Development and Testing Ch4.1. Algorithm Analysis
Introduction to Algorithms
Topics: jGRASP editor ideosyncrasies assert debugger.
Testing and Debugging.
Contest strategy.
Selenium HP Web Test Tool Training
Chapter 15 Debugging.
Navigating huge (UE4 (rendering)) code
DEBUGGING JAVA PROGRAMS USING ECLIPSE DEBUGGER
Using a Debugger 1-Jan-19.
Debugging Taken from notes by Dr. Neil Moore
Chapter 15 Debugging.
PAC Intro to “big o” Lists Professor: Evan Korth New York University
Debuggers and Debugging
Debugging Taken from notes by Dr. Neil Moore
Automated test.
CSE 1020:Software Development
Chapter 15 Debugging.
Automated test.
Presentation transcript:

Testing and Debugging pt.2 Intro to Complexity CS221 – 2/18/09

junit Create a junit file for each class Don’t share between classes – defeats the purposes How to write a test: – setup(): Any steps you need to take before testing starts – Call each of the class methods you want to test – Use junit assertions to pass/fail the test – Any exception will cause the test to fail – tearDown(): If you need to clean up after testing

Example

Debugging When to debug – To track down a defect – To understand an exception – To trace the flow of execution, understand code Key concepts – Breakpoints: stop execution and give you control – Single step: execute one line at a time – Assertions: like a debug exception

Breakpoints Line: Stops execution on the specified line Method: Stops execution on the method Watchpoint: Stops execution whenever the field is accessed or modified Exception breakpoint: Stops execution when an exception is thrown Class load breakpoint: Stops execution when a class is loaded

Breakpoint Example

Single Step Step in: Steps into the method being called Step over: Steps over the method being called Step return: Steps out to the calling method Run to line: Executes until the specified line of code

Single Step Example

Assertions Usage: – Assert something_true; If the assertion fails you’ll get an exception Requires –ea on the compiler command line Assertions should be turned off when you are not testing or debugging Where to use assertions – Preconditions: Test parameter assumptions on a private method – Test logical assumptions anywhere – Postconditions: Test your return value assumptions

Assertion Example

Debugging Tips Use inspect or variables window to see object values Use breakpoints and step through code that is complex – make sure it works as you expect it You can make changes to the code while debugging but it won’t affect execution till you restart Breakpoints on each branch will quickly tell if you have good branch coverage Use assertions to check logical conditions/assumptions in your code – Assertions check logical assumptions – Assertions only work if –ea is on compile command line

Testing and Debugging - Key Points Purpose of testing is to understand and reduce risk Unit/Integration/System/Acceptance Use JUnit tests to automate granular testing on methods and classes Black Box vs. White Box Write code with testing cost in mind Test Driven Development – Build your tests first, then implement your solution Use equivalency classes and boundary conditions to drive your testing The debugger is your friend – The more time you spend stepping through code, the better your understanding will be

Airline Program Last class we covered: – EmptyPassengerQueueException – FlightNode – FlightsList Let’s quickly go over: – Main – PassengerNode – PassengerQueue

Outlab Modify FlightsList to use an Array Add 2 methods that require search Think about time complexity Today and Friday should give you the tools to get this done

Complexity Measures – Implementation complexity (Cyclomatic) – Time complexity (Big O) – Space complexity (Also Big O) Trade offs – Simple to implement algorithm may have high time complexity – Fast insertion may require additional space – Reducing space may require additional time

Why is it Important? Allows you to see when an algorithm is untenable Allows you to compare competing algorithms and data structures Saves you from hitting dead-ends Allows you to estimate processor and storage load with increasing usage Tells you where to look when making performance improvements Allows you to make the right tradeoffs – Implementation time – Maintainability – Time to execute/responsiveness – Memory/Disk storage requirements

Time Complexity Measures how many computational steps in relation to input As the input set increases, how much impact on computation time?

Space Complexity Measures how much storage in relation to input As the input set increases, how much impact on storage requirements?

Big O Notation O(1) – Linear. Very Nice! O(log n) – Logarithmic. Nice! O(n) – Linear. Good! O(n log n) – Log-linear. Not Bad. O(n^2) – Quadratic. Getting expensive. O(n^3) – Cubic. Expensive. O(2^n) – Exponential. Ouch! O(n!) – Factorial. Holy Moly!!