SOFTWARE QUALITY ANDTESTING
What is quality ?Quality popular view:  – Something “good” but not quantifiable  – Something luxurious and classyQuality p...
DEFINITION OF QUALITY
Definition of Quality  ISO 8402 definition                                  ISO 9216 Model:  of QUALITY:                  ...
QUALITY ASPECTS
Quality Concepts •   Quality of design      – refers to characteristics designers specify for the end product to        be...
Quality Control versusQuality Assurance
Quality Control versus QualityAssurance• Quality Control (QC) is a set of activities carried out with the  main objective ...
Quality as Dealing with defects•   When people associate Quality or High Quality with software system, it is    an indicat...
Causes of softwaredefects
Causes of software defects1. Faulty requirements definition2. Client-developer communication failures3. Deliberate deviati...
Software errors, software faultsand software failures     Software development process                                    ...
Software errors, software faultsand software failures More precisely: •   An error can be a grammatical error in one or mo...
Error,faults,failures           14
Tools for Improving Quality•   Formal specification•   Self-checking code•   Program verification and validation•   Testin...
Software Testing• Software testing is a popular risk management  strategy. It is used to verify that functional  requireme...
What is Software   Testing?“Testing is the process of establishing confidence that aprogram or system does what it is supp...
Testing is NOT•   Code inspections•   Design reviews•   Configuration management•   Bug trackingThese are, along with test...
TYPES OF TESTING
Types of Testing: Scope              Execution   Unit               Manual   Module             Automated   Integra...
WHO ARE THE TESTERS?
Who Tests? Developers   Unit testing QA Team   Module testing, automated testing Software   Automated testing Desig...
Testing, debugging, Verification
TESTING AND DEBUGGING
Testing and debugging Testing is the process of determining if a program has any errors. When testing reveals an error, th...
A test/debug cycle
WHAT I TEST PLAN
Test planA test cycle is often guided by a test plan.Example: The sort program is to be tested to meet therequirements giv...
Test plan (contd.)    •   Execute the program on an empty input        sequence.    •   Test the program for robustness ag...
Test case/data    A test case is a pair consisting of test data to       be        input to the program and the expected o...
TESTING AND VERIFICATION
Testing and verificationProgram verification aims at proving the correctness ofprograms by showing that it contains no err...
Testing and verification (contd.)Testing is not a perfect technique in that a program mightcontain errors despite the succ...
Software quality assurance and          testing in   Structured programming
Structure Programming andUnstructured Programming
Structured Programming• structured programming: A technique for  organizing and coding computer programs in  which a hiera...
STRUCTURED PROGRAMMING• In structured Programming each construct has a  predictable logical structure.• This could enablin...
STRUCTURED PROGRAMMING• Sequence implements processing steps that are  essential in the specification of any algorithm.• Co...
STRUCTURED PROGRAMMING• The structured constructs were proposed to limit  the procedural design of software to a small  nu...
STRUCTURED PROGRAMMING• The use of a limited number of logical constructs  also contributes to a human understanding  proc...
STRUCTURED PROGRAMMING• The structured constructs are logical chunks that  allow a reader to recognize procedural elements...
STRUCTURED PROGRAMMING• Any program, regardless of application area or  technical complexity, can be designed and  impleme...
Unstructured programmingAll the program code written in a single continuousmain program.                   Many disadvanta...
Advantages of StructuredProgramming
Advantages of StructuredProgramming•   Easy to write:    Modular design increases the programmers productivity by    allow...
Advantages of StructuredProgramming•   Easy to debug    Since each procedure is specialized to perform just one task, a   ...
Structured programming usinggraphical design notation
Graphical Design Notation• "A picture is worth a thousand words," but its  rather important to know which picture and whic...
Graphical Design Notation• A flow chart is quite simple pictorially.• A box is used to indicate a processing step.• A diamo...
Graphical Design Notation• The sequence is represented as two processing  boxes connected by an line (arrow) of control.
Graphical Design Notation• Condition, also called if-then-else, is shown as a  decision diamond that if true, causes then-...
Graphical Design Notation• The selection (or  select-case) construct  shown in the figure is  actually an extension  of th...
Graphical Design Notation• Repetition is represented using two slightly different forms.  The do while tests a condition a...
Graphical Design Notation• The structured constructs may be nested within  one another as shown in Figure
Structured programmingusing Box diagram
The box diagram
The box diagram
The box diagram
The box diagram
Structure Programming andtesting
Structure Programming andtesting(1) guarantee that all independent paths within a  module have been exercised at least onc...
BASIS PATH TESTING
Structure Programming andtesting• BASIS PATH TESTING : Test cases derived to  check the execution of every statement in th...
What is Flow Graph Notation
Flow Graph Notation• Draw a flow graph when the logical control structure of a  module is complex. The flow graph enables yo...
Types of Logic Coverage• Statement: each statement executed at  least once• Branch: each branch traversed (and every  entr...
Types of Logic Coverage (cont’d)• Compound Condition: all combinations of  condition values at every branch statement  cov...
Control Flow Graphs                      “nodes”                       “edges”
Statement Coverage• Statement Coverage requires that each  statement will have been executed at  least once.• Simplest for...
Statement Coverage  • Statement should be executed completely or    not at all.  • For example:             IF a THEN b EN...
Branch Coverage• Branch Coverage requires that each  branch will have been traversed, and  that every program entry point ...
Branch Coverage• Attempting to cover all the paths in the software is  called path coverage• The simplest form of path tes...
Condition Coverage • A branch predicate may have   more than one condition.     input(X,Y)     if (Y<=0) or (X=0) then    ...
Condition Coverage(cont’d)• Condition Coverage requires that each  condition will have been True at least  once and False ...
Condition Coverage________________________________Print “Hello World”IF Date == “01-01-2005” AND Time ==“00:00:00” THEN   ...
Branch/Condition Coverage• Branch/Condition Coverage requires  that both Branch AND Condition  Coverage will have been ach...
Compound ConditionCoverage (cont’d)• Compound Condition Coverage requires  that all combinations of condition  values at e...
Path Coverage • Path Coverage requires that all   program paths will have been   traversed at least once. • Often describe...
Loop Coverage• Loop Coverage requires that the body  of loops be executed 0, 1, 2, t, max,  and max+1 times, where possible.
Loop Coverage (cont’d)• Rationale: (cont’d)  – Check loop re-initialization.  – Check typical number of iterations.  – Che...
Flow Graph Notation• Each circle, called a flow graph node, represents  one or more procedural statements.• A sequence of ...
Flow Graph Notation• An edge must terminate at a node, even if the  node does not represent any procedural  statements (e....
Flow Graph Notation• When compound conditions are encountered in a  procedural design, the generation of a flow graph  beco...
Flow Graph Notation• Note that a separate node is created for each of the  conditions a and b in the statement IF a OR b.•...
How to draw Control flowgraph?• Sequence:  – 1 a=5;       1  – 2 b=a*b-1;                 2                           85
How to draw Control flowgraph?• Selection:  –   1 if(a>b) then                           1  –   2       c=3;  –   3 else c...
How to draw Control flowgraph?• Iteration:           1   –   1 while(a>b){   –   2     b=b*a;                       2   – ...
Example•   int f1(int x,int y){       1•   1 while (x != y){                               2•   2 if (x>y) then•   3      ...
How to draw Control flowgraph?• Iteration:           1   –   1 while(a>b){   –   2     b=b*a;                       2   – ...
Cyclomatic Complexity• Cyclomatic complexity is a software metric that  provides a quantitative measure of the logical  co...
Cyclomatic Complexity
Complexity is computed in oneof three ways• The number of regions of the flow graph  correspond to the cyclomatic complexit...
Complexity is computed in oneof three ways• Cyclomatic complexity, V(G), for a flow graph, G,  is also defined as• where P i...
Complexity is computed in oneof three ways
How to decide no. of test cases• More important, the value for V(G) provides      us  with an upper bound for the number  ...
How to derive test cases• Using the design or code as a foundation, draw a  corresponding flow graph.• Determine the cyclom...
Example Control FlowGraph              1              2          3       4              5              6  Cyclomatic compl...
Cyclomatic complexity• Another way of computing cyclomatic  complexity:  – inspect control flow graph  – determine number ...
Example Control FlowGraph              1              2          3       4              5              6  From a visual ex...
Example•   int f1(int x,int y){•   1 while (x != y){                         1•   2 if (x>y) then                         ...
21. void   myflow(int x, int y)   {                                                  32.         int a;                y =...
White-box Test Methods•   Statement Coverage•   Decision/Branch Coverage•   Condition Coverage•   Decision/Condition Cover...
Example Code Fragment• If ((A>1) & (B=0)) then  Do;•      X=X/A;•      END;• If ((A==2) | (X>1)) then  Do;•      X=X+1;•  ...
Statement Coverage• Exercise all  statements at least  once• How many test  cases?   A=2 and B=0 (ace)
Decision/Branch Coverage• Each decision has a  true and a false  outcome at least once• How many test  cases?   A=2 and B...
Condition Coverage• Each condition in a  decision takes on all  possible outcomes at  least once• Conditions: A>1, B=0,  A...
Decision/Condition Coverage• Each condition in a decision  takes on all possible  outcomes at least once, and  each decisi...
Multiple Condition Coverage• Exercise all possible  combinations of  condition outcomes in  each decision• Conditions:  A>...
Multiple Condition Coverage• How many test  cases?   A=2, B=0, X=4   (ace)   A=2, B=1, X=1   (abe)   A=1, B=0, X=2   (a...
Path Coverage• Every unique path  through the program  is executed at least  once• How many test  cases?   A=2, B=0, X=4 ...
Graph Matrices• A graph matrix is a square matrix whose size (i.e.,  number of rows and columns) is equal to the  number o...
Graph Matrices
Graph Matrices• However, by adding a link weight to each matrix  entry, the graph matrix can become a powerful  tool for e...
Graph Matrices
STRUCTUREDPROGRAMMING
Graph Matrices for testing• A graph matrix is a square matrix whose size (i.e.,  number of rows and columns) is equal to t...
Graph Matrices for testing
Graph Matrices for testing• However, by adding a link weight to each matrix  entry, the graph matrix can become a powerful...
Graph Matrices for testing
Structured Programming and Testing1. Loop Testing2. Data Flow Testing
Loop testing.Four loops can be defined:•Simple loops•Concatenate loops•Nested loops and•Unstructured loops
Simple loop• 7 different test cases made:  –Skip loop entirely  –Only one pass through loop  –Two passes through loop  –m ...
Simple loop exampleint i;while (i >= 1 && i <= 10){  i++;              i           Number of                              ...
Nested loops• Start with inner loop. Set all other loops to  minimum values.• Conduct simple loop testing on inner loop• W...
Nested loops exampleint n = 10;for (int i = 0; i < n; i++){  …  for (int j = 0; j < n; j++){     …  }  …}
Concatenated loops • Concatenated loops can be tested   using the approach defined for simple   loops, if each of the loops...
Concatenated Loops• If independent loops, use simple loop  testing• If dependent, treat as nested loops
Concatenated loops exampleint n   = 10;int m   = 20;while   (i < n){  …}int j   = i;while   (j < m){  …}
Unstructured loops• This kind of loop must be redesigned instead of  testing.
Data Flow Testing• The data flow testing method selects test paths of  a program according to the locations of definitions...
Data Flow TestingVariables that contain data values have a defined life cycle: created, used, killed (destroyed).The "sc...
The General Idea• Data flow testing can be performed at two conceptual levels.    – Static data flow testing    – Dynamic ...
Data Flow Anomaly    Anomaly: It is an abnormal way of doing something.•       Example 1: The second definition of x overr...
Data flow analysis (DFA)’sanomalies Detects Defines/reference anomalies, such as   A variable that is defined but never ...
Data Flow Testing• Three possibilities exist for the first occurrence of  a variable through a program path:   – ~d - the ...
Data Flow TestingTime-sequenced pairs of defined (d), used (u), and killed (k):  dd - Defined and defined again—not inva...
Data Flow Testing   • A data flow graph is similar to a     control flow graph in that it shows     the processing flow th...
Data Flow TestingPerform a static test of the diagram For each variable within the  module we will examine  define-use-k...
Limitation• The tester must have sufficient programming skill  to understand the code and its control flow.• Can be very t...
Tabular Design Notation• In many software applications, a module may be  required to evaluate a complex combination of  co...
Tabular Design Notation• The table is difficult to misinterpret and may even  be used as a machine readable input to a tab...
Tabular Design Notation• The table is divided into four sections.
Tabular Design Notation• The upper left-hand quadrant contains a list of all  conditions . The lower left-hand quadrant co...
Tabular Design Notation• The right-hand quadrants form a matrix that indicates  condition combinations and the correspondi...
Tabular Design NotationThe following steps are applied to develop a decision table:1. List all actions that can be associa...
Tabular Design Notation•   Associate specific sets of conditions with specific actions, eliminating    imposible combination...
Example• If the customer account is billed using a fixed rate method, a  minimum monthly charge is assessed for consumption...
Program Design Language• Program design language (PDL), also called  structured English or pseudocode, is "a language  in ...
Program Design Language• At first glance PDL looks like a modern programming  language.• The difference between PDL and a ...
PDL characteristics• A fixed syntax of keywords that provide for all structured  constructs, data declaration, and modulari...
PDL characteristics• A basic PDL syntax should include  –   Interface description,  –   Data declaration,  –   Techniques ...
A PDL Example• The system monitors alarms for fire, smoke,  burglar, water, and temperature (e.g., furnace  breaks while h...
A PDL Example• Recall that PDL is not a programming language.  The designer can adapt as required without worry of  syntax...
A PDL Example
A PDL Example
A PDL Example
A PDL Example• Note that the designer for the security.monitor  component has used a new construct PARBEGIN . .  . ENDPAR ...
COMPARISON OF DESIGNNOTATION• Modularity. Design notation should support the  development of modular software and provide ...
COMPARISON OF DESIGNNOTATION• Machine readability. Notation that can be input  directly into a computer-based development ...
COMPARISON OF DESIGNNOTATION• Structure enforcement. The benefits of a design  approach that uses structured programming  c...
COMPARISON OF DESIGNNOTATION• Data representation. The ability to represent  local and global data is an essential element...
COMPARISON OF DESIGNNOTATION• "Code-to" ability. The software engineering task  that follows component-level design is cod...
Software Quality and Testing_Se lect18 btech
Upcoming SlideShare
Loading in …5
×

Software Quality and Testing_Se lect18 btech

749 views

Published on

18/18

Published in: Education, Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
749
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
70
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • Need to focus some testing effort on these as well (not a focus of coverage-based testing) – Explore the sequences of events related to the data state and the unreasonable things that can happen to data. – Explore the effect of using the value produced by each and every computation
  • Handouts
  • Handouts
  • The first is correct. The variable does not exist and then it is defined. The second is incorrect. A variable must not be used before it is defined. The third is probably incorrect. Destroying a variable before it is created is indicative of a programming error. d – defined, created, initialized Data declaration; on left hand side of computation k – killed, undefined, released u – used for something (=c and p) c - Right hand side of computation, pointer (calculation) p - Used in a predicate (or as control variable of loop)
  • - dd – why define twice without use? - du – normal (a “du pair”) - dk -- why define and kill without use? - ud – usually normal, reassignment after use - uu – normal - uk – normal kd – normal (kill then redefine) ku – a bug; killed then used kk – harmless but probably a bug Often these anomalies are caught by compilers or static analyzers today – depending upon the language
  • First, we will perform a static test of the diagram. By &quot;static&quot; we mean we examine the diagram (formally through inspections or informally through look-sees). Second, we perform dynamic tests on the module. By &quot;dynamic&quot; we mean we construct and execute test cases
  • Modified?????
  • Software Quality and Testing_Se lect18 btech

    1. 1. SOFTWARE QUALITY ANDTESTING
    2. 2. What is quality ?Quality popular view: – Something “good” but not quantifiable – Something luxurious and classyQuality professional view: – Conformance to requirement (Crosby, 1979)  The requirements are clearly stated and the product must conform to it  Any deviation from the requirements is regarded as a defect  A good quality product contains fewer defects – Fitness for use (Juran, 1970):  Fit to user expectations: meet user’s needs  A good quality product provides better user satisfaction 2
    3. 3. DEFINITION OF QUALITY
    4. 4. Definition of Quality ISO 8402 definition ISO 9216 Model: of QUALITY: Quality characteristics The totality of features and characteristics of a product 1.Functionality or a service that bear on 2.Reliability 3.Usability its ability to satisfy stated 4.Efficiency or implied needs 5.Maintainability 6.Portability 4
    5. 5. QUALITY ASPECTS
    6. 6. Quality Concepts • Quality of design – refers to characteristics designers specify for the end product to be constructed • Quality of conformance – degree to which design specifications are followed in manufacturing the product • Quality control – series of inspections, reviews, and tests used to ensure conformance of a work product (artifact) to its specifications • Quality assurance – auditing and reporting procedures used to provide management with data needed to make proactive decisions 6
    7. 7. Quality Control versusQuality Assurance
    8. 8. Quality Control versus QualityAssurance• Quality Control (QC) is a set of activities carried out with the main objective of withholding products from shipment if they do not qualify.• Quality Assurance (QA) is meant to minimize the costs of quality by introducing a variety of activities throughout the development process and maintenance process in order to prevent the causes of errors, detect them, and correct them in the early stages of the development. As a result, quality assurance substantially reduces the rate of non-qualifying products. 8
    9. 9. Quality as Dealing with defects• When people associate Quality or High Quality with software system, it is an indication that few, if any, defects are expected to occur during its operations or when problems do occur, the negative impact is expected to be minimized.• Key of the correctness aspect of software quality is the concept of defect, failure, fault and error.• The term “defect” refers to some problem with the software either with its external or with internal characteristics. 9
    10. 10. Causes of softwaredefects
    11. 11. Causes of software defects1. Faulty requirements definition2. Client-developer communication failures3. Deliberate deviations from software requirements4. Logical design errors5. Coding errors6. Non-compliance with documentation and coding instructions7. Shortcomings of the testing process8. User interface and procedure errors9. Documentation errors 11
    12. 12. Software errors, software faultsand software failures Software development process software error software fault software failure 12
    13. 13. Software errors, software faultsand software failures More precisely: • An error can be a grammatical error in one or more of the code lines, or a logical error in carrying out one or more of the client’s requirements. • Not all software errors become software faults. in some cases, the software error can cause improper functioning of the software. In many other cases, erroneous code lines will not affect the functionality of the software as a whole. • A failure is said to occur whenever the external behavior of a system does not conform to that prescribed in the system specification. A software fault becomes a software failure only when it is “activated” 13
    14. 14. Error,faults,failures 14
    15. 15. Tools for Improving Quality• Formal specification• Self-checking code• Program verification and validation• Testing• Deploy with capabilities to repair
    16. 16. Software Testing• Software testing is a popular risk management strategy. It is used to verify that functional requirements were met.• The limitation of this approach, however, is that by the time testing occurs, it is too late to build quality into the product 16
    17. 17. What is Software Testing?“Testing is the process of establishing confidence that aprogram or system does what it is supposed to.”by Hetzel 1973“Testing is the process of executing a program or systemwith the intent of finding errors.” by Myers 1979“Testing is any activity aimed at evaluating an attributeor capability of a program or system and determiningthat it meets its required results.” by Hetzel 1983
    18. 18. Testing is NOT• Code inspections• Design reviews• Configuration management• Bug trackingThese are, along with testing, are part of Software Quality Assurance (SQA). Together these improve the quality of the product
    19. 19. TYPES OF TESTING
    20. 20. Types of Testing: Scope  Execution  Unit  Manual  Module  Automated  Integration  Interface  Phases/Triggers  Coverage  Nightly Builds  Defect Removal Purpose  Change Order Completion  Functional  Alpha  Stress  Beta
    21. 21. WHO ARE THE TESTERS?
    22. 22. Who Tests? Developers  Unit testing QA Team  Module testing, automated testing Software  Automated testing Designers  Engineers, Analysts Users  Unpleasant but true
    23. 23. Testing, debugging, Verification
    24. 24. TESTING AND DEBUGGING
    25. 25. Testing and debugging Testing is the process of determining if a program has any errors. When testing reveals an error, the process used to determine the cause of this error and to remove it, is known as debugging.
    26. 26. A test/debug cycle
    27. 27. WHAT I TEST PLAN
    28. 28. Test planA test cycle is often guided by a test plan.Example: The sort program is to be tested to meet therequirements given earlier. Specifically, the following needs tobe done. • Execute sort on at least two input sequences, one with ``A and the other with ``D as request characters.
    29. 29. Test plan (contd.) • Execute the program on an empty input sequence. • Test the program for robustness against erroneous inputs such as ``R typed in as the request character. • All failures of the test program should be recorded in a suitable file using the Company Failure Report Form.
    30. 30. Test case/data A test case is a pair consisting of test data to be input to the program and the expected output. The test data is a set of values, one for each input variable. A test set is a collection of zero or more test cases. Sample test case for sort: Test data: <A’ 12 -29 32 > Expected output: -29 12 32
    31. 31. TESTING AND VERIFICATION
    32. 32. Testing and verificationProgram verification aims at proving the correctness ofprograms by showing that it contains no errors. This is verydifferent from testing that aims at uncovering errors in aprogram.Program verification and testing are best considered ascomplementary techniques. In practice, one can discard programverification, but not testing.
    33. 33. Testing and verification (contd.)Testing is not a perfect technique in that a program mightcontain errors despite the success of a set of tests.Verification might appear to be perfect technique as it promisesto verify that a program is free from errors. However, the personwho verified a program might have made mistake in theverification process; there might be an incorrect assumption onthe input conditions; incorrect assumptions might be maderegarding the components that interface with the program, andso on.
    34. 34. Software quality assurance and testing in Structured programming
    35. 35. Structure Programming andUnstructured Programming
    36. 36. Structured Programming• structured programming: A technique for organizing and coding computer programs in which a hierarchy of modules is used.• Each having a single entry and a single exit point, and in which control is passed downward through the structure.
    37. 37. STRUCTURED PROGRAMMING• In structured Programming each construct has a predictable logical structure.• This could enabling a reader to follow procedural flow more easily.• The constructs are sequence, condition, and repetition.
    38. 38. STRUCTURED PROGRAMMING• Sequence implements processing steps that are essential in the specification of any algorithm.• Condition provides the facility for selected processing based on some logical occurrence.• Repetition allows for looping.• These three constructs are fundamental to structured programming—an important component-level design technique.
    39. 39. STRUCTURED PROGRAMMING• The structured constructs were proposed to limit the procedural design of software to a small number of predictable operations.• Complexity metrics indicate that the use of the structured constructs reduces program complexity and thereby enhances readability, testability, and maintainability.
    40. 40. STRUCTURED PROGRAMMING• The use of a limited number of logical constructs also contributes to a human understanding process that is known as chunking.• To understand this process, consider the way in which you are reading this page.• You do not read individual letters but rather recognize patterns or chunks of letters that form words or phrases.
    41. 41. STRUCTURED PROGRAMMING• The structured constructs are logical chunks that allow a reader to recognize procedural elements of a module, rather than reading the design or code line by line.• Understanding is enhanced when readily recognizable logical patterns are encountered.
    42. 42. STRUCTURED PROGRAMMING• Any program, regardless of application area or technical complexity, can be designed and implemented using only the three structured constructs.• It should be noted, however, that strict use of only these constructs can sometimes cause practical difficulties.
    43. 43. Unstructured programmingAll the program code written in a single continuousmain program. Many disadvantages for large programs • difficult to follow logic • if something needs to be done more than once must be re-typed • hard to incorporate other code • not easily modified • difficult to test particular portions of the code • ...
    44. 44. Advantages of StructuredProgramming
    45. 45. Advantages of StructuredProgramming• Easy to write: Modular design increases the programmers productivity by allowing them to look at the big picture first and focus on details later. Several Programmers can work on a single, large program, each working on a different module Studies show structured programs take less time to write than standard programs. Procedures written for one program can be reused in other programs requiring the same task. A procedure that can be used in many programs is said to be reusable
    46. 46. Advantages of StructuredProgramming• Easy to debug Since each procedure is specialized to perform just one task, a procedure can be checked individually. Older unstructured programs consist of a sequence of instructions that are not grouped for specific tasks. The logic of such programs is cluttered with details and therefore difficult to follow. Easy to Understand The relationship between the procedures shows the modular design of the program. Easy to Change Since a correctly written structured program is self-documenting, it can be easily understood by another programmer.
    47. 47. Structured programming usinggraphical design notation
    48. 48. Graphical Design Notation• "A picture is worth a thousand words," but its rather important to know which picture and which 1000 words.• There is no question that graphical tools, such as the flowchart or box diagram, provide useful pictorial patterns that readily depict procedural detail.• However, if graphical tools are misused, the wrong picture may lead to the wrong software.
    49. 49. Graphical Design Notation• A flow chart is quite simple pictorially.• A box is used to indicate a processing step.• A diamond represents a logical condition, and arrows show the flow of control.
    50. 50. Graphical Design Notation• The sequence is represented as two processing boxes connected by an line (arrow) of control.
    51. 51. Graphical Design Notation• Condition, also called if-then-else, is shown as a decision diamond that if true, causes then-part processing to occur, and if false, invokes else-part processing.
    52. 52. Graphical Design Notation• The selection (or select-case) construct shown in the figure is actually an extension of theif-then-else. A parameter is tested by successive decisions until a true condition occurs and a case part processing path is
    53. 53. Graphical Design Notation• Repetition is represented using two slightly different forms. The do while tests a condition and executes a loop task repetitively as long as the condition holds true.• A repeat until executes the loop task first, then tests a condition and repeats the task until the condition fails.
    54. 54. Graphical Design Notation• The structured constructs may be nested within one another as shown in Figure
    55. 55. Structured programmingusing Box diagram
    56. 56. The box diagram
    57. 57. The box diagram
    58. 58. The box diagram
    59. 59. The box diagram
    60. 60. Structure Programming andtesting
    61. 61. Structure Programming andtesting(1) guarantee that all independent paths within a module have been exercised at least once,(2) exercise all logical decisions on their true and false sides,(3) execute all loops at their boundaries and within their operational bounds, and(4) exercise internal data structures to ensure their validity.
    62. 62. BASIS PATH TESTING
    63. 63. Structure Programming andtesting• BASIS PATH TESTING : Test cases derived to check the execution of every statement in the program at least one time during testing. – Flow Graph Notation – Cyclomatic Complexity – Deriving Test Cases – Graph Matrices
    64. 64. What is Flow Graph Notation
    65. 65. Flow Graph Notation• Draw a flow graph when the logical control structure of a module is complex. The flow graph enables you to trace program paths more readily.
    66. 66. Types of Logic Coverage• Statement: each statement executed at least once• Branch: each branch traversed (and every entry point taken) at least once• Condition: each condition True at least once and False at least once• Branch/Condition: both Branch and Condition coverage achieved
    67. 67. Types of Logic Coverage (cont’d)• Compound Condition: all combinations of condition values at every branch statement covered (and every entry point taken)• Path: all program paths traversed at least once
    68. 68. Control Flow Graphs “nodes” “edges”
    69. 69. Statement Coverage• Statement Coverage requires that each statement will have been executed at least once.• Simplest form of logic coverage.• Also known as Node Coverage.
    70. 70. Statement Coverage • Statement should be executed completely or not at all. • For example: IF a THEN b ENDIF is considered as more than 1 statement since b may or may not be executed depending on the condition a.
    71. 71. Branch Coverage• Branch Coverage requires that each branch will have been traversed, and that every program entry point will have been taken, at least once.• Also known as Edge Coverage.
    72. 72. Branch Coverage• Attempting to cover all the paths in the software is called path coverage• The simplest form of path testing is called branch testing________________________________Print “Hello World”IF Date == “01-01-2005” THEN Print “Happy New Year”ELSE Print “Have a good day!”END IFPrint “The date is: ”+DatePrint “The time is: ”+TimeEND________________________________• To test each branch you would need to execute 2 test cases, one with the date set to 1st Jan 2005, and another with any other date.
    73. 73. Condition Coverage • A branch predicate may have more than one condition. input(X,Y) if (Y<=0) or (X=0) then Y := -Y end_if while (Y>0) and (not EOF) do input(X) Y := Y-1 end_while
    74. 74. Condition Coverage(cont’d)• Condition Coverage requires that each condition will have been True at least once and False at least once.
    75. 75. Condition Coverage________________________________Print “Hello World”IF Date == “01-01-2005” AND Time ==“00:00:00” THEN Print “Happy New Year”ELSE Print “Have a good day!”END IFPrint “The date is: ”+DatePrint “The time is: ”+TimeEND________________________________• Condition Coverage takes extra conditions into consideration• To achieve full condition coverage you would need 4 test cases
    76. 76. Branch/Condition Coverage• Branch/Condition Coverage requires that both Branch AND Condition Coverage will have been achieved.• Therefore, Branch/Condition Coverage subsumes both Branch Coverage and Condition Coverage.
    77. 77. Compound ConditionCoverage (cont’d)• Compound Condition Coverage requires that all combinations of condition values at every branch statement will have been covered, and that every entry point will have been taken, at least once.• Also know as Multiple Condition Coverage.• Subsumes Branch/Condition Coverage, regardless of the order in which conditions are evaluated.
    78. 78. Path Coverage • Path Coverage requires that all program paths will have been traversed at least once. • Often described as the “strongest” form of logic coverage? • Path Coverage is usually impossible when loops are present. (How many test cases would be required to cover all paths in the example below?)
    79. 79. Loop Coverage• Loop Coverage requires that the body of loops be executed 0, 1, 2, t, max, and max+1 times, where possible.
    80. 80. Loop Coverage (cont’d)• Rationale: (cont’d) – Check loop re-initialization. – Check typical number of iterations. – Check upper (valid) bound on number of times body may be executed. – If the maximum can be exceeded, what behavior results?
    81. 81. Flow Graph Notation• Each circle, called a flow graph node, represents one or more procedural statements.• A sequence of process boxes and a decision diamond can map into a single node.• The arrows on the flow graph, called edges or links, represent flow of control and are analogous to flowchart arrows.
    82. 82. Flow Graph Notation• An edge must terminate at a node, even if the node does not represent any procedural statements (e.g., see the symbol for the if-then- else construct).• Areas bounded by edges and nodes are called regions.• When counting regions, we include the area outside the graph as a region.
    83. 83. Flow Graph Notation• When compound conditions are encountered in a procedural design, the generation of a flow graph becomes slightly more complicated.• A compound condition occurs when one or more Boolean operators (logical OR, AND, NAND, NOR) is present in a conditional statement.
    84. 84. Flow Graph Notation• Note that a separate node is created for each of the conditions a and b in the statement IF a OR b.• Each node that contains a condition is called a predicate node and is characterized by two or more edges emanating from it.
    85. 85. How to draw Control flowgraph?• Sequence: – 1 a=5; 1 – 2 b=a*b-1; 2 85
    86. 86. How to draw Control flowgraph?• Selection: – 1 if(a>b) then 1 – 2 c=3; – 3 else c=5; 2 3 – 4 c=c*c; 4 86
    87. 87. How to draw Control flowgraph?• Iteration: 1 – 1 while(a>b){ – 2 b=b*a; 2 – 3 b=b-1;} – 4 c=b+d; 3 4 87
    88. 88. Example• int f1(int x,int y){ 1• 1 while (x != y){ 2• 2 if (x>y) then• 3 x=x-y; 3 4• 4 else y=y-x; 5• 5}• 6 6 return x; } 88
    89. 89. How to draw Control flowgraph?• Iteration: 1 – 1 while(a>b){ – 2 b=b*a; 2 – 3 b=b-1;} – 4 c=b+d; 3 4 89
    90. 90. Cyclomatic Complexity• Cyclomatic complexity is a software metric that provides a quantitative measure of the logical complexity of a program.• It defines the number of independent paths in the basis set of a program and provides us with an upper bound for the number of tests that must be conducted to ensure that all statements have been executed at least once.
    91. 91. Cyclomatic Complexity
    92. 92. Complexity is computed in oneof three ways• The number of regions of the flow graph correspond to the cyclomatic complexity.• Cyclomatic complexity, V(G), for a flow graph, G, is defined as• where E is the number of flow graph edges, N is the number of flow graph nodes.
    93. 93. Complexity is computed in oneof three ways• Cyclomatic complexity, V(G), for a flow graph, G, is also defined as• where P is the number of predicate nodes contained in the flow graph G.
    94. 94. Complexity is computed in oneof three ways
    95. 95. How to decide no. of test cases• More important, the value for V(G) provides us with an upper bound for the number of independent paths that form the basis set and, by implication, an upper bound on the number of tests that must be designed and executed to guarantee coverage of all program statements.
    96. 96. How to derive test cases• Using the design or code as a foundation, draw a corresponding flow graph.• Determine the cyclomatic complexity of the resultant flow graph.• Determine a basis set of linearly independent paths.• Prepare test cases that will force execution of each path in the basis set.
    97. 97. Example Control FlowGraph 1 2 3 4 5 6 Cyclomatic complexity = E-N+2 7-6+2 = 3. 97
    98. 98. Cyclomatic complexity• Another way of computing cyclomatic complexity: – inspect control flow graph – determine number of bounded areas in the graph• V(G) = Total number of bounded areas + 1 98
    99. 99. Example Control FlowGraph 1 2 3 4 5 6 From a visual examination of the CFG: the number of bounded areas is 2. 99 cyclomatic complexity = 2+1=3.
    100. 100. Example• int f1(int x,int y){• 1 while (x != y){ 1• 2 if (x>y) then 2• 3 x=x-y;• 4 else y=y-x; 3 4• 5} 5• 6 return x; } 6 • Number of independent paths: 3 – 1,6 test case (x=1, y=1) – 1,2,3,5,1,6 test case(x=1, y=2) 100 – 1,2,4,5,1,6 test case(x=2, y=1)
    101. 101. 21. void myflow(int x, int y) { 32. int a; y == 0 y != 03. if (y == 0) {4. a = 1; 4 65. } else {6. a = y; 7 }7. y = y – 1;8. if (a > 0) { a>0 8 a≤09. a = x;10. } else { 9 1111. a = x + 1; }12. printf(“%dn”, a); 12 } 101
    102. 102. White-box Test Methods• Statement Coverage• Decision/Branch Coverage• Condition Coverage• Decision/Condition Coverage• Path Coverage
    103. 103. Example Code Fragment• If ((A>1) & (B=0)) then Do;• X=X/A;• END;• If ((A==2) | (X>1)) then Do;• X=X+1;• END;• END;
    104. 104. Statement Coverage• Exercise all statements at least once• How many test cases?  A=2 and B=0 (ace)
    105. 105. Decision/Branch Coverage• Each decision has a true and a false outcome at least once• How many test cases?  A=2 and B=0 (ace)  A=1 and X=1 (abd)
    106. 106. Condition Coverage• Each condition in a decision takes on all possible outcomes at least once• Conditions: A>1, B=0, A=2, X>1• How many test cases?  A=2, B=0, and X=4 (ace)  A=1, B=1, and X=1 (abd)
    107. 107. Decision/Condition Coverage• Each condition in a decision takes on all possible outcomes at least once, and each decision takes on all possible outcomes at least once• How many test cases?  A=2, B=0, and X=4 (ace)  A=1, B=1, and X=1 (abd)• What about these?  A=1, B=0, and X=3 (abe)  A=2, B=1, and X=1 (abe)
    108. 108. Multiple Condition Coverage• Exercise all possible combinations of condition outcomes in each decision• Conditions: A>1, B=0 A=2, X>1 A>1, B<>0 A=2, X<=1 A<=1, B=0 A<>2, X>1 A<=1, B<>0 A<>2, X<=1
    109. 109. Multiple Condition Coverage• How many test cases?  A=2, B=0, X=4 (ace)  A=2, B=1, X=1 (abe)  A=1, B=0, X=2 (abe)  A=1, B=1, X=1 (abd)
    110. 110. Path Coverage• Every unique path through the program is executed at least once• How many test cases?  A=2, B=0, X=4 (ace)  A=2, B=1, X=1 (abe)  A=3, B=0, X=1 (acd)  A=1, B=1, X=1 (abd)
    111. 111. Graph Matrices• A graph matrix is a square matrix whose size (i.e., number of rows and columns) is equal to the number of nodes on the flow graph.• Each row and column corresponds to an identified node, and matrix entries correspond to connections (an edge) between nodes.
    112. 112. Graph Matrices
    113. 113. Graph Matrices• However, by adding a link weight to each matrix entry, the graph matrix can become a powerful tool for evaluating program control structure during testing.• The link weight provides additional information about control flow.• In its simplest form, the link weight is 1 (a connection exists) or 0 (a connection does not exist).
    114. 114. Graph Matrices
    115. 115. STRUCTUREDPROGRAMMING
    116. 116. Graph Matrices for testing• A graph matrix is a square matrix whose size (i.e., number of rows and columns) is equal to the number of nodes on the flow graph.• Each row and column corresponds to an identified node, and matrix entries correspond to connections (an edge) between nodes.
    117. 117. Graph Matrices for testing
    118. 118. Graph Matrices for testing• However, by adding a link weight to each matrix entry, the graph matrix can become a powerful tool for evaluating program control structure during testing.• The link weight provides additional information about control flow.• In its simplest form, the link weight is 1 (a connection exists) or 0 (a connection does not exist).
    119. 119. Graph Matrices for testing
    120. 120. Structured Programming and Testing1. Loop Testing2. Data Flow Testing
    121. 121. Loop testing.Four loops can be defined:•Simple loops•Concatenate loops•Nested loops and•Unstructured loops
    122. 122. Simple loop• 7 different test cases made: –Skip loop entirely –Only one pass through loop –Two passes through loop –m passes through loop (m < n, where n is the maximum number) –n–1 –n –n+1
    123. 123. Simple loop exampleint i;while (i >= 1 && i <= 10){ i++; i Number of iterations} 0 or 11 0 (Skip loop entirely) 10 1 (one pass) 9 2 (two passes) 5 6 (pass M times) 2 9 (pass n – 1 times) 1 10 (pass n times) 0 0 (pass n + 1 times)
    124. 124. Nested loops• Start with inner loop. Set all other loops to minimum values.• Conduct simple loop testing on inner loop• Work outwards• Continue until all loops tested
    125. 125. Nested loops exampleint n = 10;for (int i = 0; i < n; i++){ … for (int j = 0; j < n; j++){ … } …}
    126. 126. Concatenated loops • Concatenated loops can be tested using the approach defined for simple loops, if each of the loops is independent of the other. • However, if two loops are concatenated and the loop counter for loop 1 is used as the initial value for loop 2, then the loops are not independent. • When the loops are not independent, the approach applied to nested loops is recommended.
    127. 127. Concatenated Loops• If independent loops, use simple loop testing• If dependent, treat as nested loops
    128. 128. Concatenated loops exampleint n = 10;int m = 20;while (i < n){ …}int j = i;while (j < m){ …}
    129. 129. Unstructured loops• This kind of loop must be redesigned instead of testing.
    130. 130. Data Flow Testing• The data flow testing method selects test paths of a program according to the locations of definitions and uses of variables in the program• Data flow testing is a powerful tool to detect improper use of data values due to coding errors – Incorrect assignment or input statement – Definition is missing (use of null definition) – Predicate is faulty (incorrect path is taken which leads to incorrect definition) 130
    131. 131. Data Flow TestingVariables that contain data values have a defined life cycle: created, used, killed (destroyed).The "scope" of the variable { // begin outer block int x; // x is defined as an integer within this outer block ...; // x can be accessed here { // begin inner block int y; // y is defined within this inner block ...; // both x and y can be accessed here } // y is automatically destroyed at the end of // this block ...; // x can still be accessed, but y is gone } // x is automatically destroyed 131
    132. 132. The General Idea• Data flow testing can be performed at two conceptual levels. – Static data flow testing – Dynamic data flow testing• Static data flow testing – Identify potential defects, commonly known as data flow anomaly. – Analyze source code. – Do not execute code.• Dynamic data flow testing – Involves actual program execution. – Bears similarity with control flow testing. • Identify paths to execute them. • Paths are identified based on data flow testing criteria. 132
    133. 133. Data Flow Anomaly Anomaly: It is an abnormal way of doing something.• Example 1: The second definition of x overrides the first. – x = f1(y); x = f2(z); Three types of abnormal situations with using variable.• Type 1: Defined and then defined again – Type 2: Undefined but referenced – Type 3: Defined but not referenced – 133
    134. 134. Data flow analysis (DFA)’sanomalies Detects Defines/reference anomalies, such as  A variable that is defined but never used  (unused variable)  A variable that is used but never defined  (undefined variable)  A variable that is defined twice before it is used  (redundant operations)  Data reads from location not previously written to  (uninitialized variables) The anomalies can be discovered by “static analysis”
    135. 135. Data Flow Testing• Three possibilities exist for the first occurrence of a variable through a program path: – ~d - the variable does not exist (indicated by the ~), then it is defined (d) – ~u - the variable does not exist, then it is used (u) – ~k - the variable does not exist, then it is killed or destroyed (k) 135
    136. 136. Data Flow TestingTime-sequenced pairs of defined (d), used (u), and killed (k):  dd - Defined and defined again—not invalid but suspicious. Probably a programming error.  du - Defined and used—perfectly correct. The normal case.  dk - Defined and then killed—not invalid but probably a programming error.  uu - Used and used again—acceptable.  uk - Used and killed—acceptable.  kd - Killed and defined—acceptable. A variable is killed and then redefined.  ku - Killed and used—a serious defect. Using a variable that does not exist or is undefined is always an error.  kk - Killed and killed—probably a programming error 136
    137. 137. Data Flow Testing • A data flow graph is similar to a control flow graph in that it shows the processing flow through a module. In addition, it details the definition, use, and destruction of each of the modules variables. • Technique – Construct diagrams – Perform a static test of the diagram – Perform dynamic tests on the module 137
    138. 138. Data Flow TestingPerform a static test of the diagram For each variable within the module we will examine define-use-kill patterns along the control flow paths The define-use-kill patterns for x (taken in pairs as we follow the paths) are: ~define - correct, the normal case define-define - suspicious, perhaps a programming error define-use - correct, the normal case  138
    139. 139. Limitation• The tester must have sufficient programming skill to understand the code and its control flow.• Can be very time consuming because of all the modules and basis paths that comprise a system 139
    140. 140. Tabular Design Notation• In many software applications, a module may be required to evaluate a complex combination of conditions and select appropriate actions based on these conditions.• Decision tables provide a notation that translates actions and conditions into a tabular form.
    141. 141. Tabular Design Notation• The table is difficult to misinterpret and may even be used as a machine readable input to a table driven algorithm.
    142. 142. Tabular Design Notation• The table is divided into four sections.
    143. 143. Tabular Design Notation• The upper left-hand quadrant contains a list of all conditions . The lower left-hand quadrant contains a list of all actions that are possible based on combinations of conditions.
    144. 144. Tabular Design Notation• The right-hand quadrants form a matrix that indicates condition combinations and the corresponding actions that will occur for a specific combination. Therefore, each column of the matrix may be interpreted as a processing rule.
    145. 145. Tabular Design NotationThe following steps are applied to develop a decision table:1. List all actions that can be associated with a specific procedure (or module).2. List all conditions (or decisions made) during execution of the procedure.
    146. 146. Tabular Design Notation• Associate specific sets of conditions with specific actions, eliminating imposible combinations of conditions; alternatively, develop every possible permutation of conditions.• Define rules by indicating what action(s) occurs for a set of conditions.
    147. 147. Example• If the customer account is billed using a fixed rate method, a minimum monthly charge is assessed for consumption of less than 100 KWH (kilowatt-hours).• Otherwise, computer billing applies a Schedule A rate structure.• However, if the account is billed using a variable rate method, a Schedule A rate structure will apply to consumption below 100 KWH, with additional consumption billed according to Schedule B
    148. 148. Program Design Language• Program design language (PDL), also called structured English or pseudocode, is "a language in that it uses the vocabulary of one language (i.e., English) and the overall syntax of a structured programming language.• A program design language may be a simple transposition of a language such C.
    149. 149. Program Design Language• At first glance PDL looks like a modern programming language.• The difference between PDL and a real programming language lies in the use of narrative text (e.g., English) embedded directly within PDL statements.• Given the use of narrative text embedded directly into a syntactical structure, PDL cannot be compiled (at least not yet).• However, PDL tools currently exist to translate PDL into a programming language “skeleton” and/or a graphical representation (e.g., a flowchart) of design.
    150. 150. PDL characteristics• A fixed syntax of keywords that provide for all structured constructs, data declaration, and modularity characteristics.• A free syntax of natural language that describes processing features.• Data declaration facilities that should include both simple (scalar, array) and complex (linked list or tree) data structures.• Subprogram description and calling techniques that support various modes of interface description.
    151. 151. PDL characteristics• A basic PDL syntax should include – Interface description, – Data declaration, – Techniques for block structuring, – Condition constructs, – Repetition constructs, – I/O constructs. The format and semantics for some of these
    152. 152. A PDL Example• The system monitors alarms for fire, smoke, burglar, water, and temperature (e.g., furnace breaks while homeowner is away ) and produces an alarm bell and calls a monitoring service, generating a voice-synthesized message.
    153. 153. A PDL Example• Recall that PDL is not a programming language. The designer can adapt as required without worry of syntax errors.
    154. 154. A PDL Example
    155. 155. A PDL Example
    156. 156. A PDL Example
    157. 157. A PDL Example• Note that the designer for the security.monitor component has used a new construct PARBEGIN . . . ENDPAR that specifies a parallel block.• All tasks specified within the PARBEGIN block are executed in parallel.
    158. 158. COMPARISON OF DESIGNNOTATION• Modularity. Design notation should support the development of modular software and provide a means for interface specification.• Overall simplicity. Design notation should be relatively simple to learn, relatively easy to use, and generally easy to read.• Ease of editing. The procedural design may require modification as the software process proceeds. The ease with which a design representation can be edited can help facilitate each software engineering task.
    159. 159. COMPARISON OF DESIGNNOTATION• Machine readability. Notation that can be input directly into a computer-based development system offers significant benefits.• Maintainability. Software maintenance is the most costly phase of the software life cycle. Maintenance of the software configuration nearly always means maintenance of the procedural design representation.
    160. 160. COMPARISON OF DESIGNNOTATION• Structure enforcement. The benefits of a design approach that uses structured programming concepts have already been discussed. Design notation that enforces the use of only the structured constructs promotes good design practice.• Automatic processing. A procedural design contains information that can be processed to give the designer new or better insights into the correctness and quality of a design. Such insight can be enhanced with reports provided via software design tools.
    161. 161. COMPARISON OF DESIGNNOTATION• Data representation. The ability to represent local and global data is an essential element of component-level design. Ideally, design notation should represent such data directly.• Logic verification. Automatic verification of design logic is a goal that is paramount during software testing. Notation that enhances the ability to verify logic greatly improves testing adequacy.
    162. 162. COMPARISON OF DESIGNNOTATION• "Code-to" ability. The software engineering task that follows component-level design is code generation. Notation that may be converted easily to source code reduces effort and error.

    ×