PROGRAMMING TESTING 201300071-1B MODULE 2: SOFTWARE SYSTEMS 22 NOVEMBER 2013.

Slides:



Advertisements
Similar presentations
Object Oriented Analysis And Design-IT0207 iiI Semester
Advertisements

Defect testing Objectives
Lecture 8: Testing, Verification and Validation
White Box and Black Box Testing Tor Stålhane. What is White Box testing White box testing is testing where we use the info available from the code of.
Annoucements  Next labs 9 and 10 are paired for everyone. So don’t miss the lab.  There is a review session for the quiz on Monday, November 4, at 8:00.
1 Software Engineering Lecture 11 Software Testing.
FIT FIT1002 Computer Programming Unit 19 Testing and Debugging.
CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
Object Oriented Design An object combines data and operations on that data (object is an instance of class) data: class variables operations: methods Three.
1 CODE TESTING Principles and Alternatives. 2 Testing - Basics goal - find errors –focus is the source code (executable system) –test team wants to achieve.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing.
Testing an individual module
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Swami NatarajanJuly 14, 2015 RIT Software Engineering Reliability: Introduction.
1 Functional Testing Motivation Example Basic Methods Timing: 30 minutes.
Software Testing Verification and validation planning Software inspections Software Inspection vs. Testing Automated static analysis Cleanroom software.
Unit Testing & Defensive Programming. F-22 Raptor Fighter.
System/Software Testing
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
Software Quality Assurance Lecture #8 By: Faraz Ahmed.
1 Software Testing (Part-II) Lecture Software Testing Software Testing is the process of finding the bugs in a software. It helps in Verifying and.
Coverage tools Program is typically compiled with special options, to add extra source or object code. –Additional data structures, such as a flow graph,
Chapter 12: Software Testing Omar Meqdadi SE 273 Lecture 12 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
CS4311 Spring 2011 Unit Testing Dr. Guoqiang Hu Department of Computer Science UTEP.
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.
Chapter 8 – Software Testing Lecture 1 1Chapter 8 Software testing The bearing of a child takes nine months, no matter how many women are assigned. Many.
Software Testing Testing principles. Testing Testing involves operation of a system or application under controlled conditions & evaluating the results.
1 Software testing. 2 Testing Objectives Testing is a process of executing a program with the intent of finding an error. A good test case is in that.
CS /51 Illinois Institute of Technology CS487 Software Engineering Software Testing Techniques Mr. David A. Lash.
07 Coding Conventions. 2 Demonstrate Developing Local Variables Describe Separating Public and Private Members during Declaration Explore Using System.exit.
Testing Workflow In the Unified Process and Agile/Scrum processes.
Software Testing. 2 CMSC 345, Version 4/12 Topics The testing process  unit testing  integration and system testing  acceptance testing Test case planning.
Dr. Tom WayCSC Testing and Test-Driven Development CSC 4700 Software Engineering Based on Sommerville slides.
Software Testing Reference: Software Engineering, Ian Sommerville, 6 th edition, Chapter 20.
CSE403 Software Engineering Autumn 2001 More Testing Gary Kimura Lecture #10 October 22, 2001.
Testing Testing Techniques to Design Tests. Testing:Example Problem: Find a mode and its frequency given an ordered list (array) of with one or more integer.
Black Box Testing Techniques Chapter 7. Black Box Testing Techniques Prepared by: Kris C. Calpotura, CoE, MSME, MIT  Introduction Introduction  Equivalence.
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
16 October Reminder Types of Testing: Purpose  Functional testing  Usability testing  Conformance testing  Performance testing  Acceptance.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 22 Slide 1 Software Verification, Validation and Testing.
Software Testing Reference: Software Engineering, Ian Sommerville, 6 th edition, Chapter 20.
Software Construction Lecture 18 Software Testing.
(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.
1 Phase Testing. Janice Regan, For each group of units Overview of Implementation phase Create Class Skeletons Define Implementation Plan (+ determine.
CS Data Structures I Chapter 2 Principles of Programming & Software Engineering.
(1) A beginners guide to testing Philip Johnson Collaborative Software Development Laboratory Information and Computer Sciences University of Hawaii Honolulu.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
CS451 Lecture 10: Software Testing Yugi Lee STB #555 (816)
Theory and Practice of Software Testing
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming - Week.
Chapter 1 Software Engineering Principles. Problem analysis Requirements elicitation Software specification High- and low-level design Implementation.
PROGRAMMING PRE- AND POSTCONDITIONS, INVARIANTS AND METHOD CONTRACTS B MODULE 2: SOFTWARE SYSTEMS 13 NOVEMBER 2013.
Dynamic Testing.
Chapter 12: Software Testing Omar Meqdadi SE 273 Lecture 12 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
1 Phase Testing. Janice Regan, For each group of units Overview of Implementation phase Create Class Skeletons Define Implementation Plan (+ determine.
Software Testing Reference: Software Engineering, Ian Sommerville, 6 th edition, Chapter 20.
Verification vs. Validation Verification: "Are we building the product right?" The software should conform to its specification.The software should conform.
Testing It is much better to have a plan when testing your programs than it is to just randomly try values in a haphazard fashion. Testing Strategies:
1 Sections 7.2 – 7.7 Nested Control Statements Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Testing and Debugging UCT Department of Computer Science Computer Science 1015F Hussein Suleman March 2009.
Testing Tutorial 7.
Chapter 3: Using Methods, Classes, and Objects
About the Presentations
Testing and Test-Driven Development CSC 4700 Software Engineering
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
CSE 1020:Software Development
Presentation transcript:

PROGRAMMING TESTING B MODULE 2: SOFTWARE SYSTEMS 22 NOVEMBER 2013

Week 1 Values, conditions Classes, objects Week 2 Specifications Testing Week 3 Abstraction, inheritance Week 4 Interfaces, abstract classes Arrays Week 5 Collections Generic structures Week 6 Exceptions Stream I/O GUIs Week 7 Concurrency Networking Week 8 Security Week 9/10 Project Software Systems - Programming 2 OVERVIEW PROGRAMMING LINE

 System testing & unit testing  Test plan  Test framework  Test coverage Nino & Hosch: Chapter 6 Tool support: Emma (EclEmma for Eclipse) Self study: Nino & Hosch: Chapters 7 & 8 Software Systems - Programming 3 CONTENTS

 System testing (functional testing)  Complete system, final configuration  Test system behavior, e.g., use cases  Typically performed by testing team  Unit testing  Class, method, etc. in isolation  Test unit’s behavior  Typically performed by developer of unit  Further tests: Performance ∼, Stress ∼, Platform ∼, Usability ∼  Out of scope for this course Software Systems - Programming 4 OVERVIEW: TESTING TERMINOLOGY

 Test whether the system or unit  Behaves as intended  When used in the specified way  Plan:  List of execution scenarios  Describe how to perform scenario  Describe expected outcome Software Systems - Programming 5 TEST PLAN

 Use cases as execution scenarios, consider  Alternative flows in use cases  Different values used in use cases  Additional requirements  Treat system as “black box”  Internal structure is unknown  Validation by observing behavior Software Systems - Programming 6 TEST PLAN: SYSTEM TESTING

 One test plan per class or method, can also be  Per group of logically related methods  Per group of classes in the same hierarchy  Consider method contracts, test that  The postcondition of methods holds  When the precondition is satisfied  Treat method as “white box”  Internal structure is known  E.g., consider conditionals  Validation: by inspecting method result and/or instance/class variables Software Systems - Programming 7 TEST PLAN: UNIT TESTING Lecture will further focus on unit testing. For the project, you need to perform both, system and unit tests! Lecture will further focus on unit testing. For the project, you need to perform both, system and unit tests!

 Identify relevant cases Example: Lock  Four cases  Attempt to open in open state  Attempt to open in closed state  Attempt to close in open state  Attempt to close in closed state  Actually many more situations: Do we have to test for all possible values?  1000 possibilities for lockCode  1000 possibilities for code passed to enterDigits →isOpen() →isOpen() code correct →not isOpen() Software Systems - Programming 8 TEST CASES Lock -int lockCode +boolean isOpen() +void close() +void enterDigits(int code) > 2,000,000 combinations

 Do we have to test for all possible values?  NO! Pick representative values  What is representative?  Group values for which the unit under test behaves the same  Pick samples from this group  Random value  Boundaries (e.g,. maximum and minimum)  E.g,. for the Lock: pick 0, 123, 999 Software Systems - Programming 9 TEST CASES

 Developers are like to make mistakes at boundaries  So called off-by-one errors Example: ModuloCounter  Specification  Count from 0 up to 9  When increasing with a value of 9, reset to 0 instead  Test  Invoke increase: zero times, five times, nine times, ten times Software Systems - Programming 10 BOUNDARY CASES ModuloCounter -int value +int getValue() +void increase() this.value = this.value + 1; if (value >= 9) { this.value = 0: } off-by-one error

 Primarily test for correct behaviour when input is within specified bounds  Sometimes we want to test that nothing bad happens when input is wrong  E.g., data entered through the user interface  Test robustness of software  Can only be tested if the system behavior for wrong input is specified  E.g., usage of default values instead of wrong input  Beware: documenting behaviour outside specified precondition encourages to ignore preconditions!  Specification of exceptional behaviour: see week 6 Software Systems - Programming 11 TESTING ILLEGAL DATA

 One class per test plan  Implement each test case as method  Test method uses unit under test and asserts correct behaviour  Compare actual outcome with expected outcome  Often test cases share preparatory tasks, e.g., creating instance of class under test  Extract shared code into setUp() method  setUp() method executed before each test method  Establishes defined initial situation Software Systems - Programming 12 COMMON STRUCTURE OF UNIT TEST

 JUnit (  Provides framework for writing and running unit tests  Uses Java features not introduced in this course  Provided: simplified version of Junit  Main class ( Test )  Test class per class-under-test  Main class is executable (has main method)  Instantiates and test classes and invokes their method runTest()  Test classes implement test plan  Method runTest() must:  invoke each test method  invoke setUp() before each test method Software Systems - Programming 13 TEST FRAMEWORK

 If my code passes all tests, I’m done!  Is this correct?  How do I assure a good quality of my tests?  Systematically develop tests based on contracts  Review tests  Measure coverage  Other techniques, not covered in this course Software Systems - Programming 14 QUALITY OF TESTS

 Statement  Each statement executed at least once  Branch  E ach branch traversed (and every entry point taken) at least once  Path  All program paths traversed at least once Software Systems - Programming 15 TYPES OF COVERAGE

 100% coverage difficult to achieve  Especially for branch or path coverage, too many test cases would be needed  Synthetic code generated by compiler  Dead code (should be eliminated when discovered)  Code handling exceptional situations  High statement coverage generally possible (e.g., > 80%) Software Systems - Programming 16 GOALS FOR CODE COVERAGE

 Open-source tool  Supports class, method, and line coverage.  “Fractional” line coverage supported, but not branch coverage.  Eclipse plugin EclEmma also available  Software Systems - Programming 17 EMMA

Software Systems - Programming 18 EMMA COVERAGE REPORT

Software Systems - Programming 19 EMMA SOURCE CODE ANNOTATIONS

Software Systems - Programming 20 FRACTIONAL LINE COVERAGE Only part of conditional executed Loop increment not executed

 Java compiler may emit multiple copies of code, e.g., for instance field initializer  Emma expects coverage of all copies Software Systems - Programming 21 ANOMALIES IN REPORTED COVERAGE  Java compiler may generate default code, e.g., for missing constructors  Emma also reports coverage of such code

 Iterative process  Perform unit tests always after functionality is complete  Test from the beginning of the implementation  Extending implementation requires extending test plan  Test results lead to further coding  Test coverage results lead to extending test plan  Philosophies  “Code a little, test a little”  “Test a little, code a little” (test-driven development, test first) Software Systems - Programming 22 TESTING / DEVELOPMENT PROCESS

 Test plan  System tests based on use cases  Unit tests based on method contracts  Test representatives and boundary cases  Confirm quality of your tests by measuring their code coverage Software Systems - Programming 23 MAIN POINTS