Testing. Have you contacted your project members lately?

Slides:



Advertisements
Similar presentations
More Sophisticated Behaviour 1 Using library classes to implement more advanced functionality.
Advertisements

Comp1004: Building Better Classes I Testing and Debugging Partly based on BlueJ Book – Chapter 6.
Collections & Loops Chapter 5 Copyright © 2012 Pearson Education, Inc.
Improving structure with inheritance
Grouping Objects Arrays and for loops. Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Fixed-Size Collections.
Well-behaved objects 4.0 Testing. 2 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Main concepts to.
Objects and Classes First Programming Concepts. 14/10/2004Lecture 1a: Introduction 2 Fundamental Concepts object class method parameter data type.
Grouping Objects 3 Iterators, collections and the while loop.
Well-behaved objects Debugging. 2 Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Prevention vs Detection.
Objects First with Java A Practical Introduction using BlueJ
String Concatenation (operator overloading) 3.0.
Understanding class definitions Looking inside classes 3.0.
Well-behaved objects Improving your coding skills 1.0.
Testing and Debugging. Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling (Reminder) Zuul Assignment Two.
Grouping Objects 2 Collections and the for-each loop Collections and the while loop.
Grouping Objects 1 Introduction to Collections.
Make Sure You Know All This!. Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling 2 Objects and Classes.
STREAM STREAM A software process The Mañana Principle The Mañana Principle Don’t try to everything at once! Static Methods Static Methods Stateless Utility.
Object interaction Creating cooperating objects 5.0.
CO320 Introduction to Object- Oriented Programming Michael Kölling 3.0.
Testing a program Remove syntax and link errors: Look at compiler comments where errors occurred and check program around these lines Run time errors:
ECE122 L9: While loops March 1, 2007 ECE 122 Engineering Problem Solving with Java Lecture 9 While Loops.
5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
CS1101: Programming Methodology Aaron Tan.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
Random, Collections & Loops Chapter 5 Copyright © 2012 Pearson Education, Inc.
Java Programming, 3e Concepts and Techniques Chapter 2 - Part 2 Creating a Java Application and Applet.
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.
5.0 Objects First with Java A Practical Introduction using BlueJ Introduction to Computer Science I Instructor: Allyson Anderson.
1 COS 260 DAY 1 Tony Gauvin. 2 Agenda Class roll call Instructor Introduction Instructor’s Educational Philosophy Contract on Classroom Behavior Syllabus.
Objects First With Java A Practical Introduction Using BlueJ Grouping objects Collections and iterators 2.0.
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.
Well-behaved objects Main concepts to be covered Testing Debugging Test automation Writing for maintainability Objects First with Java - A Practical.
Grouping objects Collections and iterators Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Main.
Understanding class definitions
More about inheritance Exploring polymorphism 5.0.
5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
Final Review. From ArrayLists to Arrays The ArrayList : used to organize a list of objects –It is a class in the Java API –the ArrayList class uses an.
OOPDA Intro 5.0. Topics Website and Syllabus Rowan VPN and H:drive BlueJ application and projects Programming Style (Appendix J) Javadoc (Appendix I)
Objects First With Java A Practical Introduction Using BlueJ Grouping objects Collections and iterators 1.0.
Objects First With Java A Practical Introduction Using BlueJ Well-behaved objects 2.1.
1 COS 260 DAY 15 Tony Gauvin. 2 Agenda Questions? 6 th Mini quiz Today –Chapter 6 Assignment 4 posted –Due Nov 9 Capstone progress reports are due –Brief.
1 COS 260 DAY 12 Tony Gauvin. 2 Agenda Questions? 5 th Mini quiz –Chapter 5 40 min Assignment 3 Due Assignment 4 will be posted later (next week) –If.
Well-behaved objects Main concepts to be covered Testing Debugging Test automation Writing for maintainability Objects First with Java - A Practical.
Principles of Programming CSEB134 : BS/ CHAPTER Fundamentals of the C Programming Language.
CSE 501N Fall ’09 07: Iteration 17 September 2009 Nick Leidenfrost.
Grouping objects Iterators, collections and the while loop Equality and Equality == and equals(…)
Well-behaved objects Main concepts to be covered Testing Debugging Test automation Writing for maintainability © 2017 Pearson Education, Inc. Hoboken,
Review. Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Objects and Classes Objects and Classes –State.
Objektorienterad programmering d2, förel. 6
Objects First with Java
Chapter 4 Repetition Statements (loops)
Objects and Classes CITS1001 week 1.
Objektorienterad programmering d2, förel. 6
Testing and Debugging.
Loop Structures.
COS 260 DAY 17 Tony Gauvin.
Objects First with Java
COS 260 DAY 16 Tony Gauvin.
COS 260 DAY 15 Tony Gauvin.
Exercise 1 Declare a constant of type int called SIZE and initialize it to value 10 Declare two int arrays of size “SIZE” Assume that those int arrays.
COS 260 DAY 16 Tony Gauvin.
Objects First with Java A Practical Introduction using BlueJ
Understanding class definitions
Collections and iterators
PROGRAMMING FUNDAMENTALS Lecture # 03. Programming Language A Programming language used to write computer programs. Its mean of communication between.
Objects First with Java A Practical Introduction using BlueJ
Collections and iterators
Presentation transcript:

Testing

Have you contacted your project members lately?

Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Assignment 3 Two deliverables: Two deliverables: Code (to your submission folder)Code (to your submission folder) Report (to your submission folder or hard copy to the CAS office by 4pm)Report (to your submission folder or hard copy to the CAS office by 4pm)

Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Code snippet of the day public void test () { int sum = 1; for (int i = 0; i <= 4; i++); { sum = sum + 1; } System.out.println ("The result is: " + sum); System.out.println ("Double result: " + sum + sum); } What is the output?

Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling public void test () { int sum = 1; for (int i = 0; i <= 4; i++); { sum = sum + 1; } System.out.println ("The result is: " + sum); System.out.println ("Double result: " + sum + sum); } Code snippet of the day What is the output? The result is: This semi-colon marks the end of an empty statement, which is the loop body. This code block follows the loop. With the semi-colon above, it is not the loop body.

Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling The result is: The result is: Double result is: Code snippet of the day public void test () { int sum = 1; for (int i = 0; i <= 4; i++); { sum = sum + 1; } System.out.println ("The result is: " + sum); System.out.println ("Double result: " + sum + sum); } What is the output? This arithmetic is never done – the number is converted to a string and appended to the opening string (twice).

Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling We have to deal with errors Early errors are usually syntax errors: Early errors are usually syntax errors: –the compiler will spot these Later errors are usually logic errors: Later errors are usually logic errors: –the compiler cannot help with these –also known as bugs Some logical errors have intermittent manifestation with no obvious trigger: Some logical errors have intermittent manifestation with no obvious trigger: –also known as bugs Commercial software is rarely error free: Commercial software is rarely error free: –often, it is much worse than this … ******

Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Prevention vs Detection (Developer vs Maintainer) We can lessen the likelihood of errors: We can lessen the likelihood of errors: –encapsulate data in fields of an object –design each class to be responsible for one kind of thing We can improve the chances of detection: We can improve the chances of detection: –write documentation as we go –think about how to test as we go –test as we go (e.g. interact with classes/objects/methods using the facilities of BlueJ, build a suite of testing classes – see Unit Testing and Regression Testing in Chapter 6) We can develop detection skills. We can develop detection skills.

Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Testing and Debugging These are crucial skills. These are crucial skills. Testing searches for the presence of errors. Testing searches for the presence of errors. Debugging searches for the source of errors. Debugging searches for the source of errors. –the manifestation of an error may well occur some ‘distance’ from its source.

Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Unit Testing Each unit of an application may be tested: Each unit of an application may be tested: –each method –each class –each package Can (should) be done during development: Can (should) be done during development: –finding and fixing early lowers development costs (e.g. programmer time). –finding problems after deployment is very expensive. This is what usually happens. –if the system design lacks cohesion and has high coupling between units, the bugs may never be found and, if found, be unfixable.

Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Testing Fundamentals Understand what the unit should do (its contract): Understand what the unit should do (its contract): –look for violations (negative tests) –look for fulfillment (positive tests) Test boundaries: Test boundaries: –for example, search an empty collection –for example, add to a full collection

Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Unit Testing within BlueJ Objects of individual classes can be created. Objects of individual classes can be created. Individual methods can be invoked. Individual methods can be invoked. Inspectors provide an up-to-date view of an object’s state. Inspectors provide an up-to-date view of an object’s state. Explore through the diary-prototype project (Chapter 6). This contains bugs. Explore through the diary-prototype project (Chapter 6). This contains bugs.

Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Test Automation Good testing is a creative process. Good testing is a creative process. Thorough testing is time consuming and repetitive. Thorough testing is time consuming and repetitive. Regression testing involves re-running tests whenever anything is changed. Regression testing involves re-running tests whenever anything is changed. Use of a test rig can relieve some of the burden: Use of a test rig can relieve some of the burden: –write classes to perform the testing –creativity focused in creating these – BlueJ offers help for this: explore the project (Chapter 6). Human checking of the results still needed here.explore the diary-testing project (Chapter 6). Human checking of the results still needed here. explore the projects (Chapter 6). Machine checking of results – human intervention only if one or more checks fail.explore the diary-test-junit projects (Chapter 6). Machine checking of results – human intervention only if one or more checks fail.

Objects First with Java - A Practical Introduction using BlueJ, © David J. Barnes, Michael Kölling Review Unit testing (with BlueJ ) –Chapter 6.3 Test automation (with BlueJ ) –Chapter 6.4 Manual walkthroughs (read the code!!!) –Chapter 6.8 Print statements (see what’s happening) –Chapter 6.9 Debuggers (with BlueJ ) –Chapter , 6.11