REFACTORING & SOFTWARE TESTING. Refactoring  Refactoring is the process of altering source code so as to leave its existing functionality unchanged.

Slides:



Advertisements
Similar presentations
Testing Relational Database
Advertisements

Software Testing. Quality is Hard to Pin Down Concise, clear definition is elusive Not easily quantifiable Many things to many people You'll know it when.
Test Yaodong Bi.
1 Integration Testing CS 4311 I. Burnstein. Practical Software Testing, Springer-Verlag, 2003.
Software Quality Assurance Plan
CMSC 345, Version 11/07 SD Vick from S. Mitchell Software Testing.
Illinois Institute of Technology
Computer Engineering 203 R Smith Agile Development 1/ Agile Methods What are Agile Methods? – Extreme Programming is the best known example – SCRUM.
Testing an individual module
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
Outline Types of errors Component Testing Testing Strategy
Chapter 11: Testing The dynamic verification of the behavior of a program on a finite set of test cases, suitable selected from the usually infinite execution.
Introduction to Software Testing
Software Testing & Strategies
BY RAJESWARI S SOFTWARE TESTING. INTRODUCTION Software testing is the process of testing the software product. Effective software testing will contribute.
Functional Testing Test cases derived from requirements specification document – Black box testing – Independent testers – Test both valid and invalid.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Software Testing Verification and validation planning Software inspections Software Inspection vs. Testing Automated static analysis Cleanroom software.
BY: GARIMA GUPTA MCA FINAL YEAR WHAT IS SOFTWARE TESTING ? SOFTWARE TESTING IS THE PROCESS OF EXECUTING PROGRAMS OR SYSTEM WITH THE INTENT.
System/Software Testing
Testing. What is Testing? Definition: exercising a program under controlled conditions and verifying the results Purpose is to detect program defects.
University of Palestine software engineering department Testing of Software Systems Fundamentals of testing instructor: Tasneem Darwish.
CLEANROOM SOFTWARE ENGINEERING.
Objectives Understand the basic concepts and definitions relating to testing, like error, fault, failure, test case, test suite, test harness. Explore.
CPIS 357 Software Quality & Testing
Introduction Telerik Software Academy Software Quality Assurance.
CMSC 345 Fall 2000 Unit Testing. The testing process.
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.
Software Development Software Testing. Testing Definitions There are many tests going under various names. The following is a general list to get a feel.
Testing Workflow In the Unified Process and Agile/Scrum processes.
Software Engineering Modern Approaches Eric Braude and Michael Bernstein 1.
Dr. Tom WayCSC Testing and Test-Driven Development CSC 4700 Software Engineering Based on Sommerville slides.
COMP 121 Week 1: Testing and Debugging. Testing Program testing can be used to show the presence of bugs, but never to show their absence! ~ Edsger Dijkstra.
Unit Testing 101 Black Box v. White Box. Definition of V&V Verification - is the product correct Validation - is it the correct product.
Software Construction Lecture 18 Software Testing.
TESTING LEVELS Unit Testing Integration Testing System Testing Acceptance Testing.
1 Introduction to Software Testing. Reading Assignment P. Ammann and J. Offutt “Introduction to Software Testing” ◦ Chapter 1 2.
Acceptance testing An introduction Alessandro Marchetto Fondazione Bruno Kessler - IRST.
CPSC 873 John D. McGregor Session 9 Testing Vocabulary.
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
CPSC 871 John D. McGregor Module 8 Session 1 Testing.
Software Testing. System/Software Testing Error detection and removal determine level of reliability well-planned procedure - Test Cases done by independent.
is a validation process
Software Quality Assurance and Testing Fazal Rehman Shamil.
PROGRAMMING TESTING B MODULE 2: SOFTWARE SYSTEMS 22 NOVEMBER 2013.
 Software Testing Software Testing  Characteristics of Testable Software Characteristics of Testable Software  A Testing Life Cycle A Testing Life.
Dynamic Testing.
HNDIT23082 Lecture 09:Software Testing. Validations and Verification Validation and verification ( V & V ) is the name given to the checking and analysis.
1 Phase Testing. Janice Regan, For each group of units Overview of Implementation phase Create Class Skeletons Define Implementation Plan (+ determine.
CS223: Software Engineering Lecture 31: Acceptance Testing.
SOFTWARE TESTING LECTURE 9. OBSERVATIONS ABOUT TESTING “ Testing is the process of executing a program with the intention of finding errors. ” – Myers.
1 Software Testing. 2 What is Software Testing ? Testing is a verification and validation activity that is performed by executing program code.
CPSC 372 John D. McGregor Module 8 Session 1 Testing.
Software Engineering Modern Approaches Eric Braude and Michael Bernstein 1.
Software Development.
Software Testing Strategies for building test group
Software Testing.
Software Engineering (CSI 321)
Software Engineering Modern Approaches Chapter 24. Refactoring.
Rekayasa Perangkat Lunak Part-13
John D. McGregor Session 9 Testing Vocabulary
John D. McGregor Session 9 Testing Vocabulary
John D. McGregor Session 9 Testing Vocabulary
Introduction to Software Testing
Lecture 09:Software Testing
Testing and Test-Driven Development CSC 4700 Software Engineering
Chapter 10 – Software Testing
Test Case Test case Describes an input Description and an expected output Description. Test case ID Section 1: Before execution Section 2: After execution.
Overview Activities from additional UP disciplines are needed to bring a system into being Implementation Testing Deployment Configuration and change management.
Think about your view of QA
Presentation transcript:

REFACTORING & SOFTWARE TESTING

Refactoring  Refactoring is the process of altering source code so as to leave its existing functionality unchanged.  The simplest example of refactoring is renaming  The name of variable including a class or package name is changed  When the name is changed, all references to it except for comments are automatically changed at the same time.

Refactoring - Promote Attribute to Class class Automabile { int mileage; … }  The integer variable mileage for used automobiles is more involved than a single int variable  Therefore it can be considered «Promote Attribute to Class « refactoring class Mileage { int nomMilvalue=0; //shown on odometer int engMilvalue=0; //best estimate, accounting for replacement ….. public int compute EffectiveMileage() // to obtain estimate { ….} class Automabile { Mileage mileage; …… }

Refactoring Computer – Assisted  Some refactoring is computer assisted  This takes the form a wizard that interacts with the programmer  All interactive development environments are equipped with several refactoring wizards. To use Rename in Eclipse, one can place the cursor on the variable (name) and press Shift/Alt/R. New name is name_

Using a Refactoring Wizard Shift/Alt/R 5

Fowler’s Refactoring Taxonomy  Big Refactorings (Fowler describes the refactoring at the class level and have more of an architectural impact)  Composing Methods  Moving Features Between Objects  Organizing Data  Dealing With Generalization  Simplifying Conditional Expressions  Making Method Calls Simpler 6

Big Refactoring Example I (Fowler’s Taxonomy)  Employee SoftwareEmpClericalEmp FulltimeSoftwareEmp Employee SoftwareEmpClericalEmp Status Fulltime Retired RetiredSoftwareEmp ParttimeMaintceEmp ParttimeSoftwareEmp FulltimeMaintceEmp RetiredMaintceEmp ParttimeMaintceEmp FulltimeClericalEmp RetiredClericalEmp ParttimeClericalEmp before after 7

Big Refactorings (Fowler’s Taxonomy) Example II : Convert Procedural Design to Objects  Control startGame() displayCharacter() moveCharacter() VideoGame GameCharacter VideoGame start() GameCharacter display() move() before after When an object is required to control, single call to a method is required in an appropriate object Minimal control may still be needed outside of the classes

Big Refactoring Example III: Separate Domain from Presentation  Account name balance … displayStandard() displayHTML() Account name balance … StandardAccountGUI display () HTMLAccountGUI display () before after  GUI code occurs in the same class as the computational algorithms or the data repository.  For example The Account class my perform the computations, and also produce displays

Big Refactorings (Fowler’s Taxonomy) Example IV: Extract Hierarchy  Project SoftwareEngineeringProject CustomerEntertainmentProject MobileApplication DesktopApplication before after © 2010 John Wiley & Sons Ltd.

Software Test is a validation process  Executing code from the application is provided with input and the resulting output is compared with the required output.  Testing establishes the presence of defects but not their absence  Testing Early and Often means the Agile Connection

12 Testing: Four Main Questions Testing requires significant time to decide what to test, when to do so, and with what data.  At which level conducting the testing? – Unit – Integration – System  How to choose inputs? – using the specifications/use cases/requirements – using the code  How to identify the expected output? – Test the predictions (oracles)  How good test cases are? – When we can stop the testing activity

13 Test Phases  Acceptance Testing – This checks if the overall system is functioning as required.  Unit testing – This is basically testing of a single function, procedure, class.  Integration testing – This checks that units tested in isolation work properly when put togehter.  System testing –The emphasis is to ensure that the whole system can cope with real data, monitor system performance, test the system’s error handling and recovery routines.  Regression Testing  Regression Testing – This checks that the system preserves its functionality after maintenance and/or evolution tasks.

 Suppose that C is a body of already-tested code in an application A.  Suppose that A has been altered with new or changed code N.  If C is known to depend on N Perform regression testing on C  If C is reliably known to be completely independent of N There is no need to regression test C  Otherwise Regression test C Regression Testing: What to Retest A snjfgkjfdkgjkfdjgkfdj kgjdfkbvjfdkjbkfdjbk fdjbkjdfklbjdflkbjkldf jbkfdjblkjfdklbjfdklbj klfdjbkldfjbkljdfkbljf dklbjoikhkgkjkDHVD ABFDSGKJGFJTIURjs kjgls,al40rgnsj hhjk ghjhgj ghjkklj;ljko fghjhjgfj g;b,kdfgjfjfjg kfdjk N dfkbljfdklHVDABFDS DHVDABFDSlkgt GKJGIURjskjgl C 14

What are Software Testing Types ?  Black box testing : You don't need to know the internal design in detail or have a good knowledge about the code for this test.  It's mainly based on functionality and specifications, requirements.  White box testing : This test is based on detailed knowledge of the internal design and code.  Tests are performed for specific code statements and coding styles.

Black- & White-box Testing Black box … requirements Actual output compared with required output White box Input determined by... Result …design elements Validation of expected behavior 16

Black-Box Testing  Black-Box Testing does not take the manner in which the application was designed or implemented Example: Person «a» rents « the Matrix» on May5 Person «b» rents «Gone with the Wind» on May 6 Person «a» returns «the Matrix» on May 10  This is analogous to building an automobile and then testing it by driving it under various conditions.

White-Box Testing  White -box tests are based on design and implementation  If the car is built with a new design for its automatic transmission, we would be wise to use this knowledge  White box testing is required

Unit Testing versus Post-Unit testing Reliable? Reliable part? Reliable? 19  Software applications consist of numerous parts.  Therefore the soundness of the whole depends on the soundness of the parts  Because of the dependence, we test software parts thoroughly before assembling them  A process is called as unit testing

Types of Post-Unit Testing  Interface testing Validates functions exposed by modules  Integration …… combinations of modules  System whole application  Usability user satisfaction  Regression changes did not create defects in existing code  Acceptance customer agreement that contract satisfied  Installation works as specified once installed on required platform  Robustness ability to handle anomalies  Performance fast enough; uses acceptable amount of memory 20

Post-Unit Testing Unit ….. Unit ….. Module Application on test bed Application on final platform Build ….. integration testing Interface testing system testing usability testing installation testing acceptance testing Regression testing throughout 21 Each of post-unit testing activities is performed during the process of building an application

Decide How and Where to get Test Input  Standard test stock market data for a brokerage application  Standard test chemical reactions for a chemical engineering application  Standard FDA procedures for the pharmaceutical industry  Standard test inputs for a compiler  Output from previous version of the application

Plan for Testing  Define “units” vs. non-units for testing  Determine what types of testing will be performed  Determine extent  do not just “test until time expires”  prioritize, so that important tests definitely performed  Document  individual’s personal document set included?  how / when to incorporate all types of testing?  how / when to incorporate in formal documents?  how / when to use tools / test utilities?  Determine input sources  Decide who will test  individual engineer responsible for some (units)?  how / when inspected by Qality Assurance?  how / when designed & performed by third parties?  Estimate resources  use historical data if available  Identify metrics to be collected  Define, gather, use  e.g., time, defect count, type, and source 23

Stopping Criteria for Testing  When tester has not been able to find another defect in 5 minutes of testing  When all nominal, boundary and out-of-bounds test examples show no defect  When a given checklist of test types has been completed  After completing a series of targeted coverage (e.g., branch coverage for unit testing)  When testing runs out of its scheduled time 24

25  Unit Tests are tests written by the developers to test functionality as they write it.  Each unit test typically tests only a single class, or a small cluster of classes.  Unit tests are typically written using a unit testing framework, such as JUnit (automatic unit tests).  Target errors not found by Unit testing: - Requirements are misinterpreted by developer. - Modules don’t integrate with each other Unit Testing

 Both white box and black box methods are utilized during unit testing  White box unit tests focus on  the internal code structure,  testing each program statement,  every decision point and each independent path  Black box methods focus on testing the unit without using its internal structure  Equivalence partitioning and boundary value analysis

27 + system increment Prioritized functionalities Write acceptance tests Execute acceptance tests Write and execute unit tests “At different points in the process” “Executed after the development”“Written before” Iterative Software Development

28 The motivation of unit testing is finding faults.The motivation of acceptance testing is demonstrating working functionalities. Written and executed during the development.Written before the development and executed after. Written using a unit testing framework. Written using an acceptance testing framework (also unit testing framework). Starting point: new capability (to add a new module/function or class/method). Starting point: User stories, User needs, Use Cases, Textual Requirements, … Used to find faults in individual modules or units (individual programs, functions, procedures, web pages, menus, classes, …) of source code. Used for documentation (low level) Used to verify that the implementation is complete and correct. Used for Integration, System, and regression testing. Used to indicate the progress in the development phase. (Usually as %). Used as a contract. Used for documentation (high level) (extreme programming) When unit tests pass, write another test that fails. (extreme programming) When acceptance tests pass, stop coding. The job is done. Written by developers.Written by Customer and Analyst. Unit TestsAcceptance Tests Acceptance Testing versus Unit Testing

Unit Test Methods  White-Box Methods  Statement coverage Test cases cause every line of code to be executed  Branch coverage Test cases cause every decision point to execute  Path coverage Test cases cause every independent code path to be executed  Black-Box Methods  Equivalence partitioning Divide input values into equivalent groups  Boundary Value Analysis Test at boundary conditions 29