page_title: Equivalence partitioning
hierarchical_section_title: Equivalence partitioning
caption_attribution_description: English: Equivalent Class Partitioning of safe addition of integers
context_page_description: Equivalence partitioning or equivalence class partitioning is a software testing technique that divides the input data of a software unit into partitions of equivalent data from which test cases can be derived. In principle, test cases are designed to cover each partition at least once. This technique tries to define test cases that uncover classes of errors, thereby reducing the total number of test cases that must be developed. An advantage of this approach is reduction in the time required for testing software due to lesser number of test cases.
  Equivalence partitioning is typically applied to the inputs of a tested component, but may be applied to the outputs in rare cases. The equivalence partitions are usually derived from the requirements specification for input attributes that influence the processing of the test object.
  The fundamental concept of ECP comes from equivalence class which in turn comes from equivalence relation.
  A software system is in effect a computable function implemented as an algorithm in some implementation programming language.
  Given an input test vector some instructions of that algorithm get covered, others do not.
context_section_description: Equivalence partitioning or equivalence class partitioning (ECP) is a software testing technique that divides the input data of a software unit into partitions of equivalent data from which test cases can be derived. In principle, test cases are designed to cover each partition at least once. This technique tries to define test cases that uncover classes of errors, thereby reducing the total number of test cases that must be developed. An advantage of this approach is reduction in the time required for testing software due to lesser number of test cases.
  Equivalence partitioning is typically applied to the inputs of a tested component, but may be applied to the outputs in rare cases.  The equivalence partitions are usually derived from the requirements specification for input attributes that influence the processing of the test object.
  The fundamental concept of ECP comes from equivalence class which in turn comes from equivalence relation.
  A software system is in effect a computable function implemented as an algorithm in some implementation programming language.
  Given an input test vector some instructions of that algorithm get covered, ( see code coverage for details ) others do not.
  This gives the interesting relationship between input test vectors:-
   is an equivalence relation between test vectors a, b if and only if the coverage foot print of the
  vectors a, b are exactly the same, that is, they cover the same instructions, at same step.
  This would evidently mean that the relation cover C would partition the input  vector space of the test vector  
  into multiple  equivalence class. This partitioning is called equivalence class partitioning of test input.     
  If there are N equivalent classes, only  N vectors are sufficient to fully cover the system.
  The demonstration can be done using a function written in C:
  int safe_add( int a, int b ){
      int c = a + b;
      if ( a > 0 && b > 0 && c <= 0 )
      {
          fprintf ( stderr, "Overflow (positive)!\n" );
      } 
      if ( a < 0 && b < 0 && c >= 0 )
      {
          fprintf ( stderr, "Overflow (negative)!\n" );
      } 
      return c;}
  On the basis of the code, the input vectors of [a,b] are partitioned. The blocks we need to cover are the overflow in the positive direction, negative direction, and neither of these 2. That gives rise to 3 equivalent classes, from the code review itself.
  To solve the input problem, we take refuge in the inequation  
  we note that  there is a fixed size of Integer (computer science) hence, the z can be replaced with:-
  INT_MIN ≤ x + y ≤ INT_MAX
  and
  with x ∈ { INT_MIN , ... , INT_MAX } and y ∈ { INT_MIN , ... , INT_MAX }
  The values of the test vector at the strict condition of the equality that is  INT_MIN = x + y and INT_MAX = x + y are called the boundary values, Boundary-value analysis has detailed information about it. Note that the graph only covers the overflow case, first quadrant  for X and Y positive values.
  In general an input has certain ranges which are valid and other ranges which are invalid. Invalid data here does not mean that the data is incorrect, it means that this data lies outside of specific partition. This may be best explained by the example of a function which takes a parameter "month". The valid range for the month is 1 to 12, representing January to December. This valid range is called a partition. In this example there are two further partitions of invalid ranges. The first invalid partition would be ≤ 0 and the second invalid partition would be ≥ 13.
          ... -2 -1  0 1 .............. 12 13  14  15 .....
        --------------|-------------------|---------------------
   invalid partition 1     valid partition    invalid partition 2
  The testing theory related to equivalence partitioning says that only one test case of each partition is needed to evaluate the behaviour of the program for the related partition. In other words, it is sufficient to select one test case out of each partition to check the behaviour of the program. To use more or even all test cases of a partition will not find new faults in the program. The va
caption: Demonstrating Equivalence Class Partitioning
exif: {}