1 / 60

Software Testing Techniques (STT)

Software Testing Techniques (STT). UNIT-6 logic based testing. Sudhakar yadav. Compiled with reference from: Software Testing Techniques: Boris Beizer Craft of Software Testing: Brain Marrick. CONTENTS. SYNOPSIS MOTIVATIONAL OVERVIEW

fala
Télécharger la présentation

Software Testing Techniques (STT)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Software Testing Techniques (STT) UNIT-6 logic based testing Sudhakar yadav Compiled with reference from: Software Testing Techniques: Boris Beizer Craft of Software Testing: Brain Marrick

  2. CONTENTS SYNOPSIS MOTIVATIONAL OVERVIEW DECISION TABLES (HURL83, VESS86) PATH EXPRESSIONS AGAIN KV CHARTS SPECIFICATIONS TESTABILITY TIPS

  3. SYNOPSIS Decision tables, which provide a useful basis for program and test design. Consistency and completeness can be analyzed by using boolean algebra, which can also be used as a basis for test design. Boolean algebra is trivialized by using karnaugh-veitch charts.

  4. MOTIVATIONAL OVERVIEW1. Programmers and Logic “Logic” is one of the most often used words in programmers’ vocabularies but one of their least used techniques.

  5. MOTIVATIONAL OVERVIEW2.Hardware Logic Testing Hardware logic test design, are intensely automated. Many test methods developed for hardware logic can be adapted to software logic testing. Hardware testing is ahead of software testing not because hardware testers are smarter than software testers but because hardware testing is easier. I say this from the perspective of a former hardware logic designer and tester who has worked in both camps and therefore has a basis for comparison.

  6. MOTIVATIONAL OVERVIEW3.Specification Systems and Languages (BERZ85, CHIU85, HAYE85, KEMM85, VESS86) As programming and test techniques have improved, the bugs have shifted closer to the process front end, to requirements and their specifications. Tools incorporate methods to simplify, transform, and check specifications, and the methods are to a large extent based on boolean algebra.

  7. MOTIVATIONAL OVERVIEW4. Knowledge-Based Systems The knowledge-based system (also expert system, or “artificial intelligence” system) has become the programming construct of choice for many applications that were once considered very difficult (WATE86). Knowledge-based systems incorporate knowledge from a knowledge domain such as medicine, law, or civil engineering into a database. The processing is done by a program called the inference engine

  8. MOTIVATIONAL OVERVIEW5. Overview Programmed tools are nice to have, most of the benefits of boolean algebra can be reaped by wholly manual means if you have the right conceptual tool: the karnaugh-veitch diagram is that conceptual tool.

  9. DECISION TABLES (HURL83, VESS86)3.1. Definitions and Notation Table 10.1 is a limited-entry decision table. It consists of four areas called the condition stub, the condition entry, the action stub, and the action entry. Table 10.1. An Example of a Decision Table. 1a.  Action 1 will take place if conditions 1 and 2 are met and if conditions 3 and 4 are not met (rule 1), or if conditions 1, 3, and 4 are met (rule 2).

  10. DECISION TABLES (HURL83, VESS86)3.1. Definitions and Notation Restating the conditions for action 1 to take place: 1b.  Action 1 will be taken if predicates 1 and 2 are true and if predicates 3 and 4 are false (rule 1), or if predicates 1, 3, and 4 are true (rule 2). 2.  Action 2 will be taken if the predicates are all false, (rule 3). 3.  Action 3 will take place if predicate 1 is false and predicate 4 is true (rule 4).

  11. DECISION TABLES (HURL83, VESS86)2. Decision-Table Processors Decision tables can be automatically translated into code and, as such, are a higher-order language. The decision table’s translator checks the source decision table for consistency and completeness and fills in any required default rules. The usual processing order in the resulting object code is, first, to examine rule 1. If the rule is satisfied, the corresponding action takes place. Otherwise, rule 2 is tried. This process continues until either a satisfied rule results in an action or no rule is satisfied and the default action is taken

  12. DECISION TABLES (HURL83, VESS86).3. Decision Tables as a Basis for Test Case Design The use of a decision-table model to design tests is warranted when: 1.  The specification is given as a decision table or can be easily converted into one. 2.  The order in which the predicates are evaluated does not affect interpretation of the rules or the resulting action—i.e., an arbitrary permutation of the predicate order will not, or should not, affect which action takes place. 3.  The order in which the rules are evaluated does not affect the resulting action—i.e., an arbitrary permutation of rules will not, or should not, affect which action takes place. 4.  Once a rule is satisfied and an action selected, no other rule need be examined. 5.  If several actions can result from satisfying a rule, the order in which the actions are executed doesn’t matter.

  13. DECISION TABLES (HURL83, VESS86)4. Expansion of Immaterial Cases • Immaterial entries (I) cause most decision-table contradictions. • If a condition’s truth value is immaterial in a rule, satisfying the rule does not depend on the condition. It doesn’t mean that the case is impossible. For example,

  14. DECISION TABLES (HURL83, VESS86)4. Expansion of Immaterial Cases Table 10.4 is an example of an inconsistent specification in which the expansion of two rules yields a contradiction.

  15. DECISION TABLES (HURL83, VESS86)3.5. Test Case Design (GOOD75, LEWA76, TAIA87)  If there are k rules over n binary predicates, there are at least k cases to consider and at most 2n cases. It is not usually possible to change the order in which the predicates are evaluated because that order is built into the program,*A tolerant implementation would allow these fields in any order. It is not usually possible to change the order in which the rules are evaluated because that order is built into the program, but if the implementation allows the rule evaluation order to be modified, test different orders for the rules by pairwise interchanges.  Identify the places in the routine where rules are invoked or where the processors that evaluate the rules are called. Identify the places where actions are initiated.

  16. DECISION TABLES (HURL83, VESS86)6. Decision Tables and Structure Decision tables can also be used to examine a program’s structure

  17. DECISION TABLES (HURL83, VESS86)6. Decision Tables and Structure Figure 10.1.  A Sample Program.

  18. DECISION TABLES (HURL83, VESS86)6. Decision Tables and Structure Table 10.5. The Decision Table Corresponding to Figure 10.1.

  19. DECISION TABLES (HURL83, VESS86)6. Decision Tables and Structure Table 10.6. The Expansion of Table 10.5.

  20. DECISION TABLES (HURL83, VESS86)6. Decision Tables and Structure Consider the following specification whose putative flowgraph is shown in Figure 10.2: 1.  If condition A is met, do process A1 no matter what other actions are taken or what other conditions are met. 2.  If condition B is met, do process A2 no matter what other actions are taken or what other conditions are met. 3.  If condition C is met, do process A3 no matter what other actions are taken or what other conditions are met. 4.  If none of the conditions is met, then do processes A1, A2, and A3 5.  When more than one process is done, process A1 must be done first, then A2, and then A3. The only permissible cases are: (A1), (A2), (A3), (A1,A3), (A2,A3) and (A1,A2,A3)

  21. DECISION TABLES (HURL83, VESS86)6. Decision Tables and Structure Figure 10.2.  A Troublesome Program.

  22. PATH EXPRESSIONS AGAIN1. General1. The Model Logic-based testing is structural testing when it’s applied to structure

  23. PATH EXPRESSIONS AGAIN1. General2. Predicates and Relational Operators A predicate is implemented as a process whose outcome is a truth-functional value. Don’t restrict your notion of predicate to arithmetic relations such as >, >=, =, <, <, ≠. Predicates are based on relational operators, of which the arithmetic relational operators are merely the most common

  24. PATH EXPRESSIONS AGAIN1.General3. Case Statements and Multivalued Logics Predicates need not be restricted to binary truth values (TRUE/FALSE). There are multivalued logics such as Post-algebras that can be used to analyze such predicate structures, but their use is technically difficult and semantically tricky. Three-valued logics are used routinely at the hardware interfaces between chips to reduce the number signal lines needed.

  25. PATH EXPRESSIONS AGAIN1.General4. What Goes Wrong with Predicates 1.  The wrong relational operator is used: e.g., > instead of <=. 2.  The predicate expression of a compound predicate is incorrect: e.g., A + B instead of AB. 3.  The wrong operands are used: e.g., A > X instead of A > Z. 4.  The processing leading to the predicate (along the predicate’s interpretation path) is faulty.

  26. PATH EXPRESSIONS AGAIN2.Boolean Algebra.1. Notation 1.  Label each decision with an uppercase letter that represents the truth value of the predicate. The YES or TRUE branch is labeled with a letter and the NO or FALSE branch with the same letter overscored. 2.  The truth value of a path is the product of the individual labels. Concatenation or products mean “AND.” 3.  If two or more paths merge at a node, the fact is expressed by use of a plus sign (+) which means “OR.”

  27. PATH EXPRESSIONS AGAIN2.Boolean algebra2. The Rules of Boolean Algebra Boolean algebra has three operators: × meaning AND. Also called multiplication. A statement such as AB means “A and B are both true.” This symbol is usually left out as in ordinary algebra. + meaning OR. “A + B” means “either A is true or B is true or both.” meaning NOT. Also negation or complementation. This is read as either “not A” or “A bar

  28. PATH EXPRESSIONS AGAIN2.Boolean algebra2. The Rules of Boolean Algebra laws of boolean algebra:

  29. PATH EXPRESSIONS AGAIN2.Boolean algebra3. Examples similarly

  30. PATH EXPRESSIONS AGAIN2.Boolean algebra4.Paths and Domains Each predicate on the path is denoted by a capital letter (either overscored or not). Design, or specification such that there is one and only one product term for each domain: call these d1, d2, . . . di, . . . dm. Consider any two of these product terms, di and dj. For every i not equal to j, didj must equal zero.

  31. PATH EXPRESSIONS AGAIN2.Boolean algebra5.Test Case Design 1.Simplest—Use any prime implicant in the expression to the point of interest as a basis for a path. The only values that must be taken are those that appear in the prime implicant. 2.Prime Implicant Cover—Pick input values so that there is at least one path for each prime implicant at the node of interest. 3.All Terms—Test all expanded terms for that node—for example, five terms for node 6, four for node 8, and four for node 12. That is, at least one path for each term. 4.Path Dependence—Because in general, the truth value of a predicate is obtained by interpreting the predicate, its value may depend on the path taken to get there. Do every term by every path to that term.

  32. PATH EXPRESSIONS AGAIN3.Boolean Equations Consider the flowgraph of Figure 10.3.

  33. PATH EXPRESSIONS AGAIN3.Boolean Equations Equation for before flow graphs

  34. KV CHARTS1. The Problem If you had to deal with expressions in four, five, or six variables, you could get bogged down in the algebra and make as many errors in designing test cases as there are bugs in the routine you’re testing.

  35. KV CHARTS2.Simple Forms Figure 10.4 shows all the boolean functions of a single variable and their equivalent representation as a KV chart.

  36. KV CHARTS2.Simple Forms Figure 10.5 shows eight of the sixteen possible functions of two variables.

  37. KV CHARTS2.Simple Forms Figure 10.6 shows the remaining eight functions of two variables.

  38. KV CHARTS2.Simple Forms The third example of Figure 10.6 explains rule 19

  39. KV CHARTS3. Three Variables A few examples will illustrate the principles:

  40. KV CHARTS3. Three Variables

  41. KV CHARTS3. Three Variables an example, consider

  42. KV CHARTS4. Four Variables and More The same principles hold for four and more variables.

  43. KV CHARTS4. Four Variables and More A fifth variable chart is given below

  44. KV CHARTS4. Four Variables and More For more hard sixth variable chart is there.

  45. KV CHARTS5. Even More Testing Strategies? 1.  Use one prime implicant per domain. You’ll obviously miss parts of the domain not covered by the prime implicant you chose—e.g., for disconnected domains. 2.  Use the prime implicant with the fewest variables and work down to the prime implicant with the greatest number of variables 3.  Overcome the obvious weaknesses of the above strategy (not all subdomains are covered) by using one test per prime implicant. 4.  Every term in the product form for n variables has at most n literals but, because of simplifications made possible by adjacencies, terms may have fewer than n literals, say k. Any term with k literals can be expanded into two terms with k + 1 literals

  46. SPECIFICATIONS1. General The procedure for specification validation is straightforward: 1.  Rewrite the specification using consistent terminology. 2.  Identify the predicates on which the cases are based. Name them with suitable letters, such as A, B, C. 3.  Rewrite the specification in English that uses only the logical connectives AND, OR, and NOT, however stilted it might seem. 4.  Convert the rewritten specification into an equivalent set of boolean expressions.

  47. SPECIFICATIONS1. General 5.  Identify the default action and cases, if any are specified. 6.  Enter the boolean expressions in a KV chart and check for consistency. If the specifications are consistent, there will be no overlaps, except for cases that result in multiple actions. 7.  Enter the default cases and check for consistency. 8.  If all boxes are covered, the specification is complete. 9.  If the specification is incomplete or inconsistent, translate the corresponding boxes of the KV chart back into English and get a clarification, explanation, or revision. 10.  If the default cases were not specified explicitly, translate the default cases back into English and get a confirmation.

  48. SPECIFICATIONS2. Finding and Translating the Logic • The specifications into sentences of the following form: • “IF predicate THEN action.” • If—based on, based upon, because, but, if, if and when, only if, only when, provided that, when, when or if, whenever. • Then—applies to, assign, consequently, do, implies that, infers that, initiate, means that, shall, should, then, will, would. • And—all, and, as well as, both, but, in conjunction with, coincidental with, consisting of, comprising, either . . . or, furthermore, in addition to, including, jointly, moreover, mutually, plus, together with, total, with.

  49. SPECIFICATIONS2. Finding and Translating the Logic OR—and, and if . . . then, and/or, alternatively, any of, anyone of, as well as, but, case, contrast, depending upon, each, either, either . . . or, except if, conversely, failing that, furthermore, in addition to, nor, not only . . . but, although, other than, otherwise, or, or else, on the other hand, plus. NOT—but, but not, by contrast, besides, contrary, conversely, contrast, except if, excluding, excepting, fail, failing, less, neither, never, no, not, other than. EXCLUSIVE OR—but, by contrast, conversely, nor, on the other hand, other than, or. IMMATERIAL—independent of, irregardless, irrespective, irrelevant, regardless, but not if, whether or not.

  50. SPECIFICATIONS3. Ambiguities and Contradictions Spicification Is Here is the KV chart for this specification (I’ve used the numerals 1, 2, 3, and 4 to represent the actions and the default case):

More Related