Design predicates

Design predicates

Design predicates are a method invented by Thomas McCabe, to quantify the complexity of the integration of two units of software. Each of the four types of design predicates have an associated integration complexity rating. For pieces of code that apply more than one design predicate, integration complexity ratings can be combined.

The sum of the integration complexity for a unit of code, plus one, is the maximum number of test cases necessary to exercise the integration fully. Though a test engineer can typically reduce this by covering as many previously uncovered design predicates as possible with each new test. Also, some combinations of design predicates might be logically impossible.

Contents

Types of Calls

Unconditional Call

Unit A always calls unit B. This has an integration complexity of 0. For example:

unitA::functionA() {
   unitB->functionB();
}

Conditional Call

Unit A may or may not call unit B. This integration has a complexity of 1, and needs two tests: one that calls B, and one that doesn't.

unitA::functionA() {
   if (condition) 
      unitB->functionB();
}

Mutually Exclusive Conditional Call

This is like a programming language's switch statement. Unit A calls exactly one of several possible units. Integration complexity is n - 1, where n is the number of possible units to call.

unitA::functionA() {
   switch (condition) {
      case 1:
         unitB->functionB();
         break;
      case 2:
         unitC->functionC();
         break;
      ...
      default:
         unitN->functionN();
         break;
   }
}

Iterative Call

In an iterative call, unit A calls unit B at least once, but maybe more. This integration has a complexity of 1. It also requires two tests: one that calls unit B once, and one test that calls it more than once.

unitA::functionA() {
   do {
      unitB->functionB();
   } while (condition);
}

Combining Calls

Any particular integration can combine several types of calls. For example, unit A may or may not call unit B; and if it does, it can call it one or more times. This integration combines a conditional call, with its integration complexity of 1, and an iterative call, with its integration complexity of 1. The combined integration complexity totals 2.

unitA::functionA() {
   if (someNumber > 0) {
      for ( i = 0 ; i < someNumber ; i++ ) {
         unitB->functionB();
      }
   }
}

Since the number of necessary tests is the total integration complexity plus one, this integration would require 3 tests. In one, where someNumber isn't greater than 0, unit B isn't called. In another, where someNumber is 1, unit B is called once. And in the final, someNumber is greater than 1, unit B is called more than once.

See also


Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Unit testing — In computer programming, unit testing is a method by which individual units of source code are tested to determine if they are fit for use. A unit is the smallest testable part of an application. In procedural programming a unit may be an… …   Wikipedia

  • Integration testing — (sometimes called Integration and Testing, abbreviated I T ) is the phase in software testing in which individual software modules are combined and tested as a group. It occurs after unit testing and before validation testing. Integration testing …   Wikipedia

  • Cyclomatic complexity — (or conditional complexity) is a software metric (measurement). It was developed by Thomas J. McCabe, Sr. in 1976 and is used to indicate the complexity of a program. It directly measures the number of linearly independent paths through a program …   Wikipedia

  • White box testing — Compare with black box testing .White box testing (a.k.a. clear box testing, glass box testing or structural testing) uses an internal perspective of the system to design test cases based on internal structure. It requires programming skills to… …   Wikipedia

  • Critique of Pure Reason — Part of a series on Immanuel …   Wikipedia

  • Claytronics — is an abstract future concept that combines nanoscale robotics and computer science to create individual nanometer scale computers called claytronic atoms, or catoms, which can interact with each other to form tangible 3 D objects that a user can …   Wikipedia

  • Satisfiability Modulo Theories — (SMT) problem is a decision problem for logical formulas with respect to combinations of background theories expressed in classical first order logic with equality. Examples of theories typically used in computer science are the theory of real… …   Wikipedia

  • GOD — IN THE BIBLE The Bible is not a single book, but a collection of volumes composed by different authors living in various countries over a period of more than a millennium. In these circumstances, divergencies of emphasis (cf. Kings with… …   Encyclopedia of Judaism

  • Logic programming — is, in its broadest sense, the use of mathematical logic for computer programming. In this view of logic programming, which can be traced at least as far back as John McCarthy s [1958] advice taker proposal, logic is used as a purely declarative… …   Wikipedia

  • Syntactic predicate — A syntactic predicate specifies the syntactic validity of applying a production in a formal grammar and is analogous to a semantic predicate that specifies the semantic validity of applying a production. It is a simple and effective means of… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”