Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or...

51
© Lionel Briand 2010 1 Software Verification and Validation Prof. Lionel Briand Ph.D., IEEE Fellow

Transcript of Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or...

Page 1: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 1

Software Verification and Validation

Prof. Lionel Briand Ph.D., IEEE Fellow

Page 2: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 2

Regression Testing

Page 3: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 3

References •  Mathur, A.P., “Foundations of Software Testing”, Pearson,

2008 •  Leung, K.N., White, L., “Insights into Regression Testing”,

Proc. IEEE International Conference on Software Maintenance (ICSM), pp. 60-69, 1989.

•  Rothermel, G, Harrold, M.J., “A Safe, Efficient Regression Test Selection Technique,” ACM Transactions on Software Engineering and Methodology, 6(2), pp.173-210, 1997

•  Briand, L, Labiche, Y, He, S, “Automating regression test selection based on UML designs”, Information and Software Technology (Elsevier), 2009

Page 4: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 4

Terminology

•  Regress = returning to a previous, usually worse, state •  Regression testing

–  Portion of the testing life cycle –  During which program P has been modified into program

P’ (maintenance) –  P’ needs specific testing attention to ensure that

•  newly added or modified code behaves correctly •  code carried over unchanged, continues to behave correctly

•  Important problem: –  Regression testing constitute the vast majority of testing

effort in commercial software development.

Page 5: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 5

Terminology (cont.)

•  Software Maintenance –  The process of modifying a software system or component

•  Why? –  Corrective maintenance (repairing faults), –  Perfective maintenance (changes demanded by client) –  Adaptive maintenance (adapt to new hardware/software

environment), –  Preventive maintenance (foreseeable client requests,

hardware/software environment change) •  Consequences:

–  Added code, Modified code, Deleted code, Unchanged code. •  Most of regression testing is currently white-box.

–  Added, modified, deleted, unchanged (UML) model elements. •  There is a trend to do black-box (or grey-box) regression

testing.

Page 6: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 6

Regression Testing vs. Testing Regression Testing is not a simple extension of testing Main differences are: 1.  Availability of test plan

–  Testing starts with a specification, an implementation of the specification and a test plan (black-box and/or white-box test cases). Everything is new

–  Regression testing starts with a (possibly modified) specification, a modified program, and an old test plan (which requires updating)

2.  Scope of test –  Testing aims to check the correctness of the whole program –  Regression testing aims to check (modified) parts of the

program 3.  Time allocation

–  Testing time is normally budgeted before the development of a product (part of development costs)

–  Regression testing time should be accounted for in the planning of a new release of a product

Page 7: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 7

Regression Testing vs. Testing (cont.)

4.  Development information –  During testing, knowledge about the development process is

available (it is part of it) –  During regression testing, the testers may not be the ones who

developed/tested the previous versions! 5.  Completion time

–  Completion time for regression testing should normally be much less than that for exhaustive testing (only parts are tested)

6.  Frequency –  Testing occurs frequently during code production –  Regression testing occurs many times throughout the life of a

product, once after every modification is made to it

Page 8: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 8

Two Phases of Product Development

Version 1 1.  Develop P 2.  Test P with test set T 3.  Release P

Version 2 1.  Modify P into P’ 2.  Test P’ for new functionalities 3.  Perform regression testing on P’ to

ensure that the code carried over from P behaves correctly •  Main principle: reusing tests derived

for P! •  Identifying T’, a subset of T

4.  Release P’

Page 9: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 9

Regression Testing Process

1.  Test revalidation/selection/ minimization/prioritization

2.  Test set up

3.  Test sequencing

4.  Test execution

5.  Output comparison

6.  Fault mitigation

P in modified into P’ Not all the tests for P will work on P’, some do not need to be executed, some may be redundant, there

may be too many of them and we have to rank them.

Placing P’ in its intended or simulated environment ready to receive test data.

The sequence in which tests are inputted to an application may

or may not be of concern.

The execution of the test set.

Each test needs verification

What do we do when a fault is revealed?

Page 10: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 10

Regression Testing Process (cont.) •  Test Revalidation

–  Checking which tests for P remain valid for P’. –  To ensure that only test that are applicable to P’ are used

during regression testing. –  We can identify Obsolete test cases: these are test for P that

are no longer applicable to P’ •  Test selection

–  Should we select and execute tests in T that do not traverse modified parts of P’?

–  This is the Regression Test Selection problem. –  Classification of tests:

•  Re-testable: should be re-run •  Reusable: may not need to be re-run.

  Tests in T are either Obsolete, Re-testable, or Reusable.

Page 11: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 11

Regression Testing Process (cont.) •  Test minimization

–  Discards tests seemingly redundant with respect to some criteria.

–  E.g., if two tests t1 and t2 execute function f, one might keep only t2.

–  Purpose: reducing the number of tests to execute for regression testing.

•  Test prioritization –  Prioritizing tests based on some criteria –  Context: after revalidation, selection, minimization, one may

have too many test cases (cannot afford to execute them all).

•  Comments: –  Minimization and prioritization can be considered selection

techniques. –  Minimization and prioritization techniques can be used during

testing P (not necessarily during regression testing).

Page 12: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 12

Regression Testing Process

•  Test Revalidation

•  (Regression) Test Selection

•  Test Minimization

•  Test Prioritization

Page 13: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 13

Test Revalidation •  Changes may be so drastic that tests in T won’t run on P’. •  Obsolete Test Cases:

–  Black-box or white-box test cases in T that can no longer be used on P’

•  Three ways that a test case may become obsolete: –  Program modification leads to (now) incorrect input/output

relation –  If P’s component has been modified, some test cases may

correctly specify the input/output relation, but may not be testing the same construct.

•  E.g., the modifications from P to P’ change some equivalence classes. t∈T used to exercise a boundary, which is no longer a boundary. t∈T is obsolete as it does no longer test a construct (boundary) of interest.

–  A structural test case t∈T may no longer contribute to the structural coverage of the program.

Page 14: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 14

Regression Testing Process

•  Test Revalidation

•  (Regression) Test Selection

•  Test Minimization

•  Test Prioritization

Page 15: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 15

Regression Testing Process (cont.)

T

P

P’

Functionalities retained across P and P’

Modified and newly added code

TO (obsolete) TRU

(re-usable) TRT

(re-testable)

T’

TN (new)

TRT regression tests

Page 16: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 16

The Regression Test Selection Problem

•  Let P denote the program that has been tested –  Using test set T –  Against specification S

•  Let P’ be generated by modifying P –  P’ must conform to S’

•  S and S’ could be the same (e.g., corrective maintenance) •  S⊂S’ (e.g., S’ contains new features, redefined features)

•  Regression Testing Problem –  Find a test set TRT on which P’ is to be tested to ensure that

code that implements functionalities carried over from P work correctly.

•  In addition P’ must be tested to ensure that newly added code behaves correctly.

Page 17: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 17

Regression Test Selection Techniques •  Test All

–  T’ = T - TO –  Often not a practical solution as T - TO is often too large (too

many test cases to run in the amount of time allocated) •  Random Selection

–  Select randomly tests from T - TO –  The tester decides how many tests to select –  May turn out to be better than no regression testing at all –  But may not even select tests that exercise modified parts of

the code! •  Selecting Modification Traversing Tests

–  Selecting a subset of T - TO such that only tests that guarantee the execution of modified code and code that might be impacted by the modified code in P’ are selected (TRT). (The remaining ones are TRU.)

–  A technique that does not discard any test that will traverse a modified statement is known as a “safe” regression test selection technique.

Page 18: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 18

Test Selection Using Execution Traces 1.  P is (has been) executed and execution traces are (have been)

recorded –  Execution trace = sequence of statements / nodes (CFG) hit

during one execution –  trace(t) = execution trace of test case t. –  test(n) = set of tests that hit node n at least once. We consider execution traces for T - TO.

2.  P’ is compared with P •  Build the control flow graphs G and G’ of P and P’, respectively

•  G and G’ account for control flow, as well as function calls and variable declarations

•  Identify nodes (edges) in P and P’ that are equivalent or not •  Different techniques exist

3.  Selection •  For each node n∈G that does not have an equivalent node in G’ •  T’ = T’ ∪ test(n)

Page 19: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 19

Test Selection Using Dynamic Slicing Definition: dynamic slice

–  Let P be the program under test –  Let t be a test case against which P has been executed –  Let l be a location in P where variable v is used. –  The dynamic slice of P with respect to t and v is the set of

statements/nodes (CFG) in P that lie in trace(t) and did affect the value of v at l.

1.  Computing dynamic slices –  Many different algorithms, with various complexities and

accuracies 2.  P’ is compared with P 3.  Selection

•  Let DS(t) denote a dynamic slice of P with respect to t (t∈T) and an output variable of P.

•  Let n be a node in P (CFG) modified to generate P’ •  For all output variables, if n ∈ DS(t) then re-test t (T’ = T’ ∪

{t})

Page 20: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 20

Rothermel and Harrold Study

Page 21: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 21

Regression Testing Process

•  Test Revalidation

•  (Regression) Test Selection

•  Test Minimization

•  Test Prioritization

Page 22: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 22

Test Minimization •  Regression test selection finds a subset T’ of T. •  Suppose p contains n testable entities

–  Functions, basic blocks, conditions, DU-pairs, … •  Suppose that tests in T’ cover m<n of the testable entities

–  There is likely an overlap amongst the entities covered by two tests in T’

•  Is it possible (and beneficial) to reduce T’ to T” –  such that |T”| << |T’| and –  each of the m entities covered by tests in T’ are also covered

by tests in T” •  Question

–  Will T” have the same fault detection effectiveness as T’? •  Answer

–  It depends on the modifications (from P to P’), the faults, the entities used.

Page 23: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 23

Algorithms for Test Minimization

•  Naïve algorithm –  Compute all the subsets of T’ of size 1, size 2, size 3, … and stop

when we have found one that covers all the entities covered by T’.

•  Greedy algorithm (A greedy algorithm follows the heuristic of making the locally

optimum choice at each stage with the hope of finding the global optimum.)

1.  Find t ∈T’ that covers the maximum number of entities 2.  T” = T” ∪ {t} 3.  Remove t from T’, remove the covered entities from

consideration 4.  Repeat from step 1

•  Other algorithms (e.g., genetic algorithms)

Page 24: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 24

Risk

•  Test minimization is risky –  Tests removed from T’ might be

important for finding faults in P’ – Minimization techniques are not

necessarily safe • One could discard a test that hit a modified

part of the code.

Page 25: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 25

Regression Testing Process

•  Test Revalidation

•  (Regression) Test Selection

•  Test Minimization

•  Test Prioritization

Page 26: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 26

Test Prioritization •  After regression test selection, T’ might be overly large for testing

P’ –  Not enough budget to execute all those tests.

•  Test prioritization 1.  Ranking tests (1st, 2nd, …) 2. Deciding to stop execution of tests after the nth ranked test

•  Test prioritization requires a criterion, or criteria for ranking •  Single criterion prioritization

–  Criteria 1: cost (e.g., execution time) •  Tests with lower costs are ranked first while test with

higher costs are ranked last –  Criteria 2: risk (expected risk of not executing a test)

•  Tests with higher risks are ranked first while test with lower risks are ranked last

•  Multi-criteria prioritization –  Finding a trade-off between cost and risk

Page 27: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 27

Prioritization with AHP •  Analytical Hierarchy Process (AHP)

–  Originally designed to prioritize requirements –  Use expert knowledge –  Comparing pairs and using information on pairs rather than ranking

everything at once •  Easier to compare pairs than to rank everything

1.  Pair-wise comparison of tests, assigning a value to each pair –  Different dimensions to compare pair (i,j): business value, risk of fault

-proneness, cost, frequency of use (by users)

Numerical value Explanation 1 Two test cases have equal importance. 3 Test case i has a slightly higher importance value than test case j. 5 Test case i has a strongly higher importance value than test case j. 7 Test case i has a very strongly higher importance value than test case j. 9 Test case i has an absolute higher importance value than test case j.

Reciprocals If test case i has one of the numerical values when it compares with test case j, then test case j has the reciprocal value when compared with i.

Page 28: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 28 28

Prioritization with AHP (cont.) 2.  Build a table

–  Rows and columns are test cases –  Cells show the evaluation of pairs.

3.  Modify table i.  Sum columns ii.  Divide cells by column sum iii.  Compute sum for row iv.  Divide row sum by number of test cases and

obtain a priority

TC1 TC2 TC3 TC4 TC1 1 1/3 5 7 TC2 3 1 7 9 TC3 1/5 1/7 1 1/3 TC4 1/7 1/9 3 1

1

TC1 TC2 TC3 TC4 Sum Priority TC1 0.230 0.208 0.3125 0.404 1.1545 0. 29 TC2 0.690 0.629 0.4375 0.519 2.2755 0.57 TC3 0.046 0.088 0.0625 0.019 0.2155 0.05 TC4 0.033 0.069 0.1875 0.058 0.3475 0.09 Sum 4.342 1.587 16 17.33 N/A N/A

Prioritization: TC2, TC1, TC4, TC3

Scalability issue: Instead of comparing test case pairs, compare the corresponding use cases.

Page 29: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 29

Discussion •  Regression testing requires tools (automation)

–  Instrumentation tool to compute traces –  Tools to build control flow graphs, build traces and slices –  Tools implementing selection, minimization, prioritization

algorithms •  “Un-automated regression testing is equivalent to no regression

testing.” •  Existing tools:

–  Capture/replay for GUIs –  DejaVOO (Java): research –  Telcordia Software Visualization and Analysis Toolsuite (xSuds) –  …

•  Issue: up to date coverage information •  Most research and tools perform white-box regression testing

(analysis of source code) –  There is a trend to build tools for black/grey-box (UML)

regression testing

Page 30: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 30

Detailed Applications

•  A Code-Based Regression Test Selection

•  A UML-Based Regression Test Selection

Page 31: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 31

Rothermel and Harrold

Rothermel, G, Harrold, M.J., “A Safe, Efficient Regression Test Selection Technique,” ACM Transactions on Software Engineering and Methodology, 6(2), pp.173-210, 1997

Page 32: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 32

Testing Program P

Computes the average of positive values read from a file.

Page 33: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 33

Testing Program P (cont.)

3 test cases

Coverage of edges: 011 for (P3,P4) means that only the 2nd and 3rd test cases cover this edge

Page 34: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 34

Modified Program P’

Page 35: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 35

Selection Algorithm

Determines whether the statements S and S’ associated with N and N’ are lexicographically equivalent.

Page 36: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 36

Selection Algorithm

Not lexicographically equivalent: Add test case that traverses (P4,S5), i.e.,t2

Not lexicographically equivalent: Add test case that traverses (S6,S7), i.e.,t3

T’ = {t2, t3}

Page 37: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 37

Control Flow

Page 38: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 38

Detailed Applications

•  A Code-Based Regression Test Selection

•  A UML-Based Regression Test Selection

Page 39: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 39

UML Based Regression Test Selection

•  Assumptions 1.  Each use case is described by a sequence diagram 2. Use case relationships (include/extend) described with

InteractionUse combined fragments in sequence diagrams 3.  Classes are identified as Boundary, Control, Entity classes 4. UML diagrams are consistent 5. Test cases derived from use cases and sequence diagrams:

sequence of messages •  Objectives

1.  Compare two versions of sequence diagrams, use case diagrams, and class diagrams: model version 1 (M1), model version 2 (M2)

2.  Identify obsolete, re-testable, reusable test cases in early design stages, before any change is implemented.

Page 40: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 40

Notation •  M, the set of messages

–  Messages uniquely identified by a 4-tuple: source classifier, target classifier, triggered action, triggering action

•  CF, the set of Combined Fragments –  Combined fragments are uniquely identified by a 2-tuple: their

triggering Fragment and their position in the sequence of Fragments triggered by their triggering Fragment.

•  IO, the set of interaction operands. –  Interaction operands are uniquely identified by a 2-tuple: their

triggering combined fragment and their position in their triggering combined fragment’s sequence of triggered interaction operands.

•  IU, the set of interaction uses. –  Interaction uses are uniquely identified by a 2-tuple: their

triggering Fragment and their position in their triggering Fragment’s sequence of triggered Fragments.

Page 41: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 41

Detection of Changes Definition 1—Changed message (Mc)

A changed message is a message that exists in both M1 and M2 (with identical 4-tuple) but with a different return value, arguments, or a changed action—i.e., either a changed operation or a changed signal class— as detected from class diagrams.

Definition 2—Changed combined fragment (CFc) A changed combined fragment is a combined fragment that exists in both CF1 and CF2 (with identical 2-tuple) but with a different kind (e.g., alt, opt).

Definition 3—Changed interaction operand (IOc) A changed interaction operand is an interaction operand that exists in both IO1 and IO2 (with identical 2-tuple) but with a different guard. Modifications in OCL expressions (i.e., the guards) can easily be detected by parsing and comparing them.

Definition 4—Changed interaction use (IUc) A changed interaction use is an interaction use that exists in both IU1 and IU2 (with identical 2-tuple) but with a different referred use case.

Definition 5—Changed fragment (Fc, Fc = Mc∪CFc∪IOc∪IUc) When any of the Fragments triggered by a Fragment is changed or the sequence triggered is changed we consider the triggering Fragment to be changed.

Definition 6—Deleted sequence of boundary messages (SBd) A deleted sequence of messages to boundary objects is a sequence that appears in the first version of the sequence diagrams, but not in the second version.

Page 42: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 42

Detection of Changes (cont.) Definition 7—Changed operation (ROCc)

A changed operation has the same signature in the two class diagram versions (operation name, parameter names, types and direction), but with a different property or stereotype, or with different parameter default values. We do not consider changes of visibility (public, private, protected) or scope (class, instance) because, since we assume diagrams are consistent, those changes would have either no impact on the classification of test cases or result in changes in sequence diagrams that are already handled.

Definition 8—Changed operation (ROCc), changed contracts Assuming the design by contract approach is used to specify the operations pre- and post-conditions in the OCL, changes to operation contracts (new precondition or postcondition) indicate a changed operation.

Definition 9—Changed operation (ROCc), changed class invariant Assuming the design by contract approach is used to specify class invariants in the OCL, changes to the class invariant indicate changed operations. A new invariant may require that the operation be changed to preserve that new invariant after execution.

Definition 10—Changed operation (ROCc), changed attribute If an operation accesses a changed attribute, as shown in the operation’s contracts (or invariant), the operation is considered changed. Though no change may be visible in the operation’s contracts or in the fragments the operation triggers, its implementation is likely to require some changes.

Definition 11—Changed operation (ROCc) due to a changed relationship The operation contracts show which relationships are navigated in the operation (through the OCL navigation expressions). If any of the navigated relationships in the operation’s contract (or invariant) has changed in the new class diagram, then the operation is considered changed as its execution may be affected.

Page 43: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 43

Detection of Changes (cont.)

Definition 12—Changed attribute (RACc) A changed attribute (as identified by its name) exists in both versions of a given class but with a different scope (class or instance), type (i.e., datatype), visibility (public, protected, private), multiplicity, initial value (declaration initialization or constructor changes), stereotype or property.

Definition 13—Changed relationship (Lc) A changed association is an association that exists in both class diagram versions but with a different name, kind (plain association, aggregation, composition), multiplicities, navigability, role visibility, or qualifier.

Note that we do not consider changes in role names or stereotype for changed associations as associated classes along with their roles names and the association stereotype are used to uniquely identify associations.

Association class: any change in the association class results in a change in the association. Generalization and realization relationships can only be considered changed when they are described by a stereotype that changes. Given that dependencies are uniquely identified and fully specified by their source and target classes and their stereotype, it is impossible to observe changed dependencies.

Page 44: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 44

Detection of Changes (cont.)

Definition 14—Changed class (Cc) A changed class exists in both versions of the class diagram but with a changed attribute, operation, invariant (OCL), relationship, stereotype, property, multiplicity or template.

Page 45: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 45

Classification (Definitions)

T = set of test cases S = set of sequences of messages in sequence diagrams RTS(t) = set of sequences of messages triggered by test case t RTSB(t) = set of sequences of messages to boundary objects triggered by test case t RMS = the messages (M) in sequences (S)

Page 46: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 46

Classification

Definition 15—Obsolete test case (To) A test case is obsolete if it consists of an invalid execution sequence of messages on boundary objects (SBd). This results from a change in the possible sequences according to which messages involved in the test case can be sent to boundary objects (including the addition or deletion of a message to a boundary object in the sequence diagram scenario that was mapped to the test case). (∀t∈T) RTSB

1(t) ∈ SBd ⇒ t∈To

Page 47: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 47

Classification (cont.)

Definition 16—Re-testable test case (Trt) A retestable test case is a test case which remains valid in

the new version of the design in terms of sequence of messages to boundary objects. But one or more of these messages may have changed (e.g., operation postcondition), or the set of valid sequences of messages triggered by boundary class messages may have changed (this results in changed messages according to Definition 5).

Definition 16:The set of retestable test cases, Trt, can be defined as

(∀t∈T) (∃(t,s)∈RTS)(∃(m,s)∈RMS) RTSB1(t)∉SBd ∧m∈Mc ⇒ t∈Trt

Page 48: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 48

Classification (cont.)

Definition 17—Reusable test case (Tre) A reusable test case consists of a sequence of messages to boundary objects that has remained valid in the new version of the design. The sequences of messages triggered by the boundary messages have not changed either. In other words, none of the messages involved in the test case (sent to boundary or other classes) have been changed. (∀t∈T) (∀(t,s)∈RTS)(∀(m,s)∈RMS) RTSB

1(t)∉SBd ∧m∉Mc ⇒ t∈Tre

Page 49: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 49

Case Study – IP Router •  A generic mechanism for software agents to discover and

subsequently communicate with one another in the network. •  Its main function is to register new agents as they join the

network and add them to the discovered set of agents. It also removes the terminated agents.

Page 50: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 50

Case Study - ATM

•  First change: how many times a user can provide an incorrect PIN •  Second change: restrictions on saving accounts •  Third change: change to bills (from $20 bills to $20 and $5 bills) •  Fourth change: merge two boundary classes

Page 51: Software Verification and Validation Prof. Lionel Briand Ph.D., …€¦ · – Black-box or white-box test cases in T that can no longer be used on P’ • Three ways that a test

© Lionel Briand 2010 51 51

Case Study – ATM (cont.)

Change 1

Change 2

Change 3

Change 4