Slide 14A.1 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005 Stephen R. Schach.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Slide 15.1 © The McGraw-Hill Companies, 2002 Object-Oriented and Classical Software Engineering Fifth Edition, WCB/McGraw-Hill, 2002 Stephen R. Schach.
Chapter 3: Modules, Hierarchy Charts, and Documentation
The Assembly Language Level
10 Software Engineering Foundations of Computer Science ã Cengage Learning.
Case Tools Trisha Cummings. Our Definition of CASE  CASE is the use of computer-based support in the software development process.  A CASE tool is a.
Programming Creating programs that run on your PC
© Prentice Hall CHAPTER 9 Application Development by Information Systems Professionals.
Object-Oriented Analysis and Design Lecture 10 Implementation (from Schach, “O-O and Classical Software Engineering”)
Illinois Institute of Technology
Slide 10.1 © The McGraw-Hill Companies, 2002 Object-Oriented and Classical Software Engineering Fifth Edition, WCB/McGraw-Hill, 2002 Stephen R. Schach.
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
1 Implementation Xiaojun Qi. 2 Choice of Programming Language The language is usually specified in the contract But what if the contract specifies that.
Chapter 1 Program Design
Slide 10C.52 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005 Stephen R. Schach.
Software System Integration
1 CS101 Introduction to Computing Lecture 19 Programming Languages.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 17 Slide 1 Extreme Programming.
Software Testing Sudipto Ghosh CS 406 Fall 99 November 9, 1999.
Program development & programming languages Chapter 13.
Systems Analysis – Analyzing Requirements.  Analyzing requirement stage identifies user information needs and new systems requirements  IS dev team.
Slide 14.1 CHAPTER 14 IMPLEMENTATION PHASE. Slide 14.2 Overview l Choice of programming language l Fourth generation languages l Good programming practice.
TESTING.
Implementation & Integration Phase Implementation, then integration: Implementation, then integration:  Each module is implemented by member of programmer.
Slide 15.1 Copyright © 2011 by The McGraw-Hill Companies, Inc. All rights reserved. Object-Oriented and Classical Software Engineering Eighth Edition,
Design-Making Projects Work (Chapter7) n Large Projects u Design often distinct from analysis or coding u Project takes weeks, months or years to create.
Software Testing.
Chapter 13: Implementation Phase 13.3 Good Programming Practice 13.6 Module Test Case Selection 13.7 Black-Box Module-Testing Techniques 13.8 Glass-Box.
Program Design CMSC 201. Motivation We’ve talked a lot about certain ‘good habits’ we’d like you guys to get in while writing code. There are two main.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 26 Slide 1 Software cost estimation 1.
©Ian Sommerville 2000Software Engineering, 6th edition. Chapter 23Slide 1 Chapter 23 Software Cost Estimation.
Slide 14.1 © The McGraw-Hill Companies, 2002 Object-Oriented and Classical Software Engineering Fifth Edition, WCB/McGraw-Hill, 2002 Stephen R. Schach.
Testing Basics of Testing Presented by: Vijay.C.G – Glister Tech.
Implementation 1. Software Implementation – transforming design into code Requirements Analysis Software Design Implementation Testing Deployment Evolution.
Slide 13.1 Copyright © 2008 by The McGraw-Hill Companies, Inc. All rights reserved. Object-Oriented Software Engineering WCB/McGraw-Hill, 2008 Stephen.
SE: CHAPTER 7 Writing The Program
Slide 6.1 © The McGraw-Hill Companies, 2002 Object-Oriented and Classical Software Engineering Fifth Edition, WCB/McGraw-Hill, 2002 Stephen R. Schach
Slide 11C.104 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005 Stephen R. Schach.
Cohesion and Coupling CS 4311
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 22 Slide 1 Software Verification, Validation and Testing.
INTRODUCTION TO COMPUTING CHAPTER NO. 04. Programming Languages Program Algorithms and Pseudo Code Properties and Advantages of Algorithms Flowchart (Symbols.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 6 Using Methods.
Chapter 1 Program design Objectives To describe the steps in the program development process To introduce the current program design methodology To introduce.
Slide 13.1 Copyright © 2008 by The McGraw-Hill Companies, Inc. All rights reserved. Object-Oriented Software Engineering WCB/McGraw-Hill, 2008 Stephen.
Slide 20.1 Copyright © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. An Introduction to Object-Oriented Systems Analysis and Design with.
Berrached::CS3320::Ch131 Implementation Phase Chapter 13 Classical & Object-Oriented Software Engineering by Stephen R. Schach.
Slide 15.1 Copyright © 2011 by The McGraw-Hill Companies, Inc. All rights reserved. Object-Oriented and Classical Software Engineering Eighth Edition,
 Test Plan  Testing strategies ◦ Unit testing ◦ Integration testing ◦ Product testing ◦ Acceptance testing  Test case selection  Testing Techniques.
Slide 13.1 © The McGraw-Hill Companies, 2002 Object-Oriented and Classical Software Engineering Fifth Edition, WCB/McGraw-Hill, 2002 Stephen R. Schach.
Software Engineering 2004 Jyrki Nummenmaa 1 BACKGROUND There is no way to generally test programs exhaustively (that is, going through all execution.
Integration testing Integrate two or more module.i.e. communicate between the modules. Follow a white box testing (Testing the code)
CS451 Software Implementation and Integration Yugi Lee STB #555 (816) Note: This lecture was designed.
IMPLEMENTATION. Implementation Process of translating the detailed design into code Real-life products are generally too large to be implemented by a.
Implementation Phase Programming-in-the-many Programming-in-the-many Most real-life products are too large to be implemented by one programmer Most real-life.
Object-Oriented and Classical Software Engineering Eighth Edition, WCB/McGraw-Hill Stephen R. Schach 1.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 23 Slide 1 Software testing.
Object-Oriented and Classical Software Engineering Seventh Edition, WCB/McGraw-Hill, 2010 Stephen R. Schach
Slide 7B.31 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005 Stephen R. Schach.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
Software Engineering Zhang Shuang
Slide 14.1 © The McGraw-Hill Companies, 2007 Object-Oriented and Classical Software Engineering Seventh Edition, WCB/McGraw-Hill, 2007 Stephen R. Schach.
8.4 Management of Postdelivery Maintenance
Object-Oriented and Classical Software Engineering Eighth Edition, WCB/McGraw-Hill, 2011 Stephen R. Schach 1.
Software System Integration
Object-Oriented and Classical Software Engineering Fifth Edition, WCB/McGraw-Hill, 2002 Stephen R. Schach
Programming Logic and Design Fourth Edition, Comprehensive
IMPLEMENTATION AND INTEGRATION PHASE
CHAPTER 15 IMPLEMENTATION.
Object-Oriented and Classical Software Engineering Fifth Edition, WCB/McGraw-Hill, 2002 Stephen R. Schach
Presentation transcript:

Slide 14A.1 © The McGraw-Hill Companies, 2005 Object-Oriented and Classical Software Engineering Sixth Edition, WCB/McGraw-Hill, 2005 Stephen R. Schach

Slide 14A.2 © The McGraw-Hill Companies, 2005 CHAPTER 14 — Unit A IMPLEMENTATION

Slide 14A.3 © The McGraw-Hill Companies, 2005 Overview l Choice of programming language l Fourth generation languages l Good programming practice l Coding standards l Code reuse l Integration l The implementation workflow l The implementation workflow: The Osbert Oglesby case study l The test workflow: Implementation

Slide 14A.4 © The McGraw-Hill Companies, 2005 Overview (contd) l Test case selection l Black-box unit-testing techniques l Black-box test cases: The Osbert Oglesby case study l Glass-box unit-testing technique l Code walkthroughs and inspections l Comparison of unit-testing techniques l Cleanroom l Potential problems when testing objects l Management aspects of unit testing

Slide 14A.5 © The McGraw-Hill Companies, 2005 Overview (contd) l When to rewrite rather than debug a module l Integration testing l Product testing l Acceptance testing l The test workflow: The Osbert Oglesby case study l CASE tools for implementation l Metrics for the implementation workflow l Challenges of the implementation workflow

Slide 14A.6 © The McGraw-Hill Companies, 2005 Implementation l Real-life products are generally too large to be implemented by a single programmer l This chapter therefore deals with programming-in- the-many

Slide 14A.7 © The McGraw-Hill Companies, Choice of Programming Language (contd) l The language is usually specified in the contract l But what if the contract specifies that  The product is to be implemented in the “most suitable” programming language l What language should be chosen?

Slide 14A.8 © The McGraw-Hill Companies, 2005 Choice of Programming Language (contd) l Example  QQQ Corporation has been writing COBOL programs for over 25 years  Over 200 software staff, all with COBOL expertise  What is “the most suitable” programming language? l Obviously COBOL

Slide 14A.9 © The McGraw-Hill Companies, 2005 Choice of Programming Language (contd) l What happens when new language (C++, say) is introduced  C++ professionals must be hired  Existing COBOL professionals must be retrained  Future products are written in C++  Existing COBOL products must be maintained  There are two classes of programmers »COBOL maintainers (despised) »C++ developers (paid more)  Expensive software, and the hardware to run it, are needed  100s of person-years of expertise with COBOL are wasted

Slide 14A.10 © The McGraw-Hill Companies, 2005 Choice of Programming Language (contd) l The only possible conclusion  COBOL is the “most suitable” programming language l And yet, the “most suitable” language for the latest project may be C++  COBOL is suitable for only data processing applications l How to choose a programming language  Cost–benefit analysis  Compute costs and benefits of all relevant languages

Slide 14A.11 © The McGraw-Hill Companies, 2005 Choice of Programming Language (contd) l Which is the most appropriate object-oriented language?  C++ is (unfortunately) C-like  Thus, every classical C program is automatically a C++ program  Java enforces the object-oriented paradigm  Training in the object-oriented paradigm is essential before adopting any object-oriented language l What about choosing a fourth generation language (4GL)?

Slide 14A.12 © The McGraw-Hill Companies, Fourth Generation Languages l First generation languages  Machine languages l Second generation languages  Assemblers l Third generation languages  High-level languages (COBOL, FORTRAN, C++, Java)

Slide 14A.13 © The McGraw-Hill Companies, 2005 Fourth Generation Languages (contd) l Fourth generation languages (4GLs)  One 3GL statement is equivalent to 5–10 assembler statements  Each 4GL statement was intended to be equivalent to 30 or even 50 assembler statements

Slide 14A.14 © The McGraw-Hill Companies, 2005 Fourth Generation Languages (contd) l It was hoped that 4GLs would  Speed up application-building  Result in applications that are easy to build and quick to change »Reducing maintenance costs  Simplify debugging  Make languages user friendly »Leading to end-user programming l Achievable if 4GL is a user friendly, very high-level language

Slide 14A.15 © The McGraw-Hill Companies, 2005 Fourth Generation Languages (contd) l Example  See Just in Case You Wanted to Know Box 14.2 l The power of a nonprocedural language, and the price

Slide 14A.16 © The McGraw-Hill Companies, 2005 Productivity Increases with a 4GL? l The picture is not uniformly rosy l Playtex used ADF, obtained an 80 to 1 productivity increase over COBOL  However, Playtex then used COBOL for later applications l 4GL productivity increases of 10 to 1 over COBOL have been reported  However, there are plenty of reports of bad experiences

Slide 14A.17 © The McGraw-Hill Companies, 2005 Actual Experiences with 4GLs l Many 4GLs are supported by powerful CASE tools  This is a problem for organizations at CMM level 1 or 2  Some reported 4Gl failures are due to the underlying CASE environment

Slide 14A.18 © The McGraw-Hill Companies, 2005 Actual Experiences with 4GLs (contd) l Attitudes of 43 organizations to 4GLs  Use of 4GL reduced users’ frustrations  Quicker response from DP department  4GLs are slow and inefficient, on average  Overall, 28 organizations using 4GL for over 3 years felt that the benefits outweighed the costs

Slide 14A.19 © The McGraw-Hill Companies, 2005 Fourth Generation Languages (contd) l Market share  No one 4GL dominates the software market  There are literally hundreds of 4GLs  Dozens with sizable user groups  Oracle, DB2, and PowerBuilder are extremely popular l Reason  No one 4GL has all the necessary features l Conclusion  Care has to be taken in selecting the appropriate 4GL

Slide 14A.20 © The McGraw-Hill Companies, 2005 Dangers of a 4GL l End-user programming  Programmers are taught to mistrust computer output  End users are taught to believe computer output  An end-user updating a database can be particularly dangerous

Slide 14A.21 © The McGraw-Hill Companies, 2005 Dangers of a 4GL (contd) l Potential pitfalls for management  Premature introduction of a CASE environment  Providing insufficient training for the development team  Choosing the wrong 4GL

Slide 14A.22 © The McGraw-Hill Companies, Good Programming Practice l Use of consistent and meaningful variable names  “Meaningful” to future maintenance programmers  “Consistent” to aid future maintenance programmers

Slide 14A.23 © The McGraw-Hill Companies, Use of Consistent and Meaningful Variable Names A code artifact includes the variable names freqAverage, frequencyMaximum, minFr, frqncyTotl A maintenance programmer has to know if freq, frequency, fr, frqncy all refer to the same thing  If so, use the identical word, preferably frequency, perhaps freq or frqncy, but not fr  If not, use a different word (e.g., rate ) for a different quantity

Slide 14A.24 © The McGraw-Hill Companies, 2005 Consistent and Meaningful Variable Names We can use frequencyAverage, frequencyMyaximum, frequencyMinimum, frequencyTotal We can also use averageFrequency, maximumFrequency, minimumFrequency, totalFrequency l But all four names must come from the same set

Slide 14A.25 © The McGraw-Hill Companies, The Issue of Self-Documenting Code l Self-documenting code is exceedingly rare l The key issue: Can the code artifact be understood easily and unambiguously by  The SQA team  Maintenance programmers  All others who have to read the code

Slide 14A.26 © The McGraw-Hill Companies, 2005 Self-Documenting Code Example l Example:  Code artifact contains the variable xCoordinateOfPositionOfRobotArm  This is abbreviated to xCoord  This is fine, because the entire module deals with the movement of the robot arm  But does the maintenance programmer know this?

Slide 14A.27 © The McGraw-Hill Companies, 2005 Prologue Comments l Minimal prologue comments for a code artifact Figure 14.1

Slide 14A.28 © The McGraw-Hill Companies, 2005 Other Comments l Suggestion  Comments are essential whenever the code is written in a non-obvious way, or makes use of some subtle aspect of the language l Nonsense!  Recode in a clearer way  We must never promote/excuse poor programming  However, comments can assist future maintenance programmers

Slide 14A.29 © The McGraw-Hill Companies, Use of Parameters l There are almost no genuine constants l One solution:  Use const statements (C++), or  Use public static final statements (Java) l A better solution:  Read the values of “constants” from a parameter file

Slide 14A.30 © The McGraw-Hill Companies, Code Layout for Increased Readability l Use indentation l Better, use a pretty-printer l Use plenty of blank lines  To break up big blocks of code

Slide 14A.31 © The McGraw-Hill Companies, Nested if Statements l Example  A map consists of two squares. Write code to determine whether a point on the Earth’s surface lies in map square 1 or map square 2, or is not on the map Figure 14.2

Slide 14A.32 © The McGraw-Hill Companies, 2005 Nested if Statements (contd) l Solution 1. Badly formatted Figure 14.3

Slide 14A.33 © The McGraw-Hill Companies, 2005 Nested if Statements (contd) l Solution 2. Well-formatted, badly constructed Figure 14.4

Slide 14A.34 © The McGraw-Hill Companies, 2005 Nested if Statements (contd) l Solution 3. Acceptably nested Figure 14.5

Slide 14A.35 © The McGraw-Hill Companies, 2005 Nested if Statements (contd) A combination of if-if and if-else-if statements is usually difficult to read l Simplify: The if-if combination if is frequently equivalent to the single condition if &&

Slide 14A.36 © The McGraw-Hill Companies, 2005 Nested if Statements (contd) l Rule of thumb  if statements nested to a depth of greater than three should be avoided as poor programming practice

Slide 14A.37 © The McGraw-Hill Companies, Programming Standards l Standards can be both a blessing and a curse l Modules of coincidental cohesion arise from rules like  “Every module will consist of between 35 and 50 executable statements” l Better  “Programmers should consult their managers before constructing a module with fewer than 35 or more than 50 executable statements”

Slide 14A.38 © The McGraw-Hill Companies, 2005 Remarks on Programming Standards l No standard can ever be universally applicable l Standards imposed from above will be ignored l Standard must be checkable by machine

Slide 14A.39 © The McGraw-Hill Companies, 2005 Examples of Good Programming Standards “Nesting of if statements should not exceed a depth of 3, except with prior approval from the team leader” l “Modules should consist of between 35 and 50 statements, except with prior approval from the team leader” “Use of goto s should be avoided. However, with prior approval from the team leader, a forward goto may be used for error handling”

Slide 14A.40 © The McGraw-Hill Companies, 2005 Remarks on Programming Standards (contd) l The aim of standards is to make maintenance easier  If they make development difficult, then they must be modified  Overly restrictive standards are counterproductive  The quality of software suffers

Slide 14A.41 © The McGraw-Hill Companies, Code Reuse l Code reuse is the most common form of reuse l However, artifacts from all workflows can be reused  For this reason, the material on reuse appears in Chapter 8, and not here

Slide 14A.42 © The McGraw-Hill Companies, Integration l The approach up to now:  Implementation followed by integration l This is a poor approach l Better:  Combine implementation and integration methodically

Slide 14A.43 © The McGraw-Hill Companies, 2005 Product with 13 Modules Figure 14.6

Slide 14A.44 © The McGraw-Hill Companies, 2005 Implementation, Then Integration l Code and test each code artifact separately l Link all 13 artifacts together, test the product as a whole

Slide 14A.45 © The McGraw-Hill Companies, 2005 Drivers and Stubs To test artifact a, artifacts b,c,d must be stubs  An empty artifact, or  Prints a message (" Procedure radarCalc called "), or  Returns precooked values from preplanned test cases To test artifact h on its own requires a driver, which calls it  Once, or  Several times, or  Many times, each time checking the value returned Testing artifact d requires a driver and two stubs

Slide 14A.46 © The McGraw-Hill Companies, 2005 Implementation, Then Integration (contd) l Problem 1  Stubs and drivers must be written, then thrown away after unit testing is complete l Problem 2  Lack of fault isolation  A fault could lie in any of the 13 artifacts or 13 interfaces  In a large product with, say, 103 artifacts and 108 interfaces, there are 211 places where a fault might lie

Slide 14A.47 © The McGraw-Hill Companies, 2005 Implementation, Then Integration (contd) l Solution to both problems  Combine unit and integration testing

Slide 14A.48 © The McGraw-Hill Companies, Top-down Integration If code artifact mAbove sends a message to artifact mBelow, then mAbove is implemented and integrated before mBelow l One possible top-down ordering is  a,b,c,d,e,f,g, h,i,j,k,l,m Figure 14.6 (again)

Slide 14A.49 © The McGraw-Hill Companies, 2005 Top-down Integration (contd) l Another possible top-down ordering is a [a]b,e,h [a] c,d,f,i [a,d]g,j,k,l,m Figure 14.6 (again)

Slide 14A.50 © The McGraw-Hill Companies, 2005 Top-down Integration (contd) l Advantage 1: Fault isolation  A previously successful test case fails when mNew is added to what has been tested so far »The fault must lie in mNew or the interface(s) between mNew and the rest of the product l Advantage 2: Stubs are not wasted  Each stub is expanded into the corresponding complete artifact at the appropriate step

Slide 14A.51 © The McGraw-Hill Companies, 2005 Top-down Integration (contd) l Advantage 3: Major design flaws show up early l Logic artifacts include the decision-making flow of control  In the example, artifacts a,b,c,d,g,j l Operational artifacts perform the actual operations of the product  In the example, artifacts e,f,h,i,k,l,m l The logic artifacts are developed before the operational artifacts

Slide 14A.52 © The McGraw-Hill Companies, 2005 Top-down Integration (contd) l Problem 1  Reusable artifacts are not properly tested  Lower level (operational) artifacts are not tested frequently  The situation is aggravated if the product is well designed l Defensive programming (fault shielding)  Example: if (x >= 0) y = computeSquareRoot (x, errorFlag);  computeSquareRoot is never tested with x < 0  This has implications for reuse

Slide 14A.53 © The McGraw-Hill Companies, Bottom-up Integration If code artifact mAbove calls code artifact mBelow, then mBelow is implemented and integrated before mAbove l One possible bottom-up ordering is l,m,h,i,j,k,e, f,g,b,c,d,a Figure 14.6 (again)

Slide 14A.54 © The McGraw-Hill Companies, Bottom-up Integration l Another possible bottom-up ordering is h,e,b i,f,c,d l,m,j,k,g[d] a[b,c,d] Figure 14.6 (again)

Slide 14A.55 © The McGraw-Hill Companies, 2005 Bottom-up Integration (contd) l Advantage 1  Operational artifacts are thoroughly tested l Advantage 2  Operational artifacts are tested with drivers, not by fault shielding, defensively programmed artifacts l Advantage 3  Fault isolation

Slide 14A.56 © The McGraw-Hill Companies, 2005 Bottom-up Integration (contd) l Difficulty 1  Major design faults are detected late l Solution  Combine top-down and bottom-up strategies making use of their strengths and minimizing their weaknesses

Slide 14A.57 © The McGraw-Hill Companies, Sandwich Integration l Logic artifacts are integrated top-down l Operational artifacts are integrated bottom-up l Finally, the interfaces between the two groups are tested Figure 14.7

Slide 14A.58 © The McGraw-Hill Companies, 2005 Sandwich Integration (contd) l Advantage 1  Major design faults are caught early l Advantage 2  Operational artifacts are thoroughly tested  They may be reused with confidence l Advantage 3  There is fault isolation at all times

Slide 14A.59 © The McGraw-Hill Companies, 2005 Summary Figure 14.8

Slide 14A.60 © The McGraw-Hill Companies, Integration of Object-Oriented Products l Object-oriented implementation and integration  Almost always sandwich implementation and integration  Objects are integrated bottom-up  Other artifacts are integrated top-down

Slide 14A.61 © The McGraw-Hill Companies, Management of Integration l Example:  Design document used by programmer P 1 (who coded code object o1 ) shows o1 sends a message to o2 passing 4 arguments  Design document used by programmer P 2 (who coded code artifact o2 ) states clearly that only 3 arguments are passed to o2 l Solution:  The integration process must be run by the SQA group  They have the most to lose if something goes wrong

Slide 14A.62 © The McGraw-Hill Companies, The Implementation Workflow l The aim of the implementation workflow is to implement the target software product l A large product is partitioned into subsystems  Implemented in parallel by coding teams l Subsystems consist of components or code artifacts

Slide 14A.63 © The McGraw-Hill Companies, 2005 The Implementation Workflow (contd) l Once the programmer has implemented an artifact, he or she unit tests it l Then the module is passed on to the SQA group for further testing  This testing is part of the test workflow

Slide 14A.64 © The McGraw-Hill Companies, The Implementation Workflow: The Osbert Oglesby Case Study l Complete implementations in Java and C++ can be downloaded from

Slide 14A.65 © The McGraw-Hill Companies, The Test Workflow: Implementation l Unit testing  Informal unit testing by the programmer  Methodical unit testing by the SQA group l There are two types of methodical unit testing  Non-execution-based testing  Execution-based testing

Slide 14A.66 © The McGraw-Hill Companies, Test Case Selection l Worst way — random testing  There is no time to test all but the tiniest fraction of all possible test cases, totaling perhaps or more l We need a systematic way to construct test cases

Slide 14A.67 © The McGraw-Hill Companies, Testing to Specifications versus Testing to Code l There are two extremes to testing l Test to specifications (also called black-box, data- driven, functional, or input/output driven testing)  Ignore the code — use the specifications to select test cases l Test to code (also called glass-box, logic-driven, structured, or path-oriented testing)  Ignore the specifications — use the code to select test cases

Slide 14A.68 © The McGraw-Hill Companies, Feasibility of Testing to Specifications l Example:  The specifications for a data processing product include 5 types of commission and 7 types of discount  35 test cases l We cannot say that commission and discount are computed in two entirely separate artifacts — the structure is irrelevant

Slide 14A.69 © The McGraw-Hill Companies, 2005 Feasibility of Testing to Specifications (contd) l Suppose the specifications include 20 factors, each taking on 4 values  There are 4 20 or 1.1  test cases  If each takes 30 seconds to run, running all test cases takes more than 1 million years l The combinatorial explosion makes testing to specifications impossible

Slide 14A.70 © The McGraw-Hill Companies, Feasibility of Testing to Code l Each path through a artifact must be executed at least once  Combinatorial explosion

Slide 14A.71 © The McGraw-Hill Companies, 2005 Feasibility of Testing to Code (contd) l Code example: Figure 14.9

Slide 14A.72 © The McGraw-Hill Companies, 2005 Feasibility of Testing to Code (contd) l The flowchart has over different paths Figure 14.10

Slide 14A.73 © The McGraw-Hill Companies, 2005 l Testing to code is not reliable l We can exercise every path without detecting every fault Feasibility of Testing to Code (contd) Figure 14.11

Slide 14A.74 © The McGraw-Hill Companies, 2005 l A path can be tested only if it is present l A programmer who omits the test for d = 0 in the code probably is unaware of the possible danger Feasibility of Testing to Code (contd) Figure 14.12

Slide 14A.75 © The McGraw-Hill Companies, 2005 Feasibility of Testing to Code (contd) l Criterion “exercise all paths” is not reliable  Products exist for which some data exercising a given path detect a fault, and other data exercising the same path do not

Slide 14A.76 © The McGraw-Hill Companies, 2005 Continued in Unit 14B