I have read that equivalence partitioning can be used typically for intervals or lists, e.g. I assume it can be used for every set of inputs. Anyway if the requirement says that allowed colors are (RED,BLUE,BLACK, GREEN), I cannot treat them like a list, right? I mean, testing one of them would not be enough because developers most likely used some switch-case and thus it is not real "set" where one could represent also the others. So how it is meant with lists?

Also what is not that clear to me, I do not think it is always possible to do the initial partioning and then design the test cases.
What about checking two lines intersection: Y=MX+C. (two inputs)

1) The lines are paraller. M1=M1 but C1 must be different from C2.
2) Lines are intersecting. M1 must be different from M2.
3) Coincident. The are the same.

How can I use partitioning here? THis is actually taken from a book and it says that these sets are eq.classes.

  • I've difficulties to understand what you are asking. However, an equivalence class is simply the set of all elements which are equivalent wrt some eq. relation ~ on a larger set Y. For a relation to be an eq. relation 3 properties have to hold: a~a for each a in Y, a~b => b~a and (a~b and b~c) => a~c. Taking all lines in the plane it is easy to see that being parallel is an eq. relation. A theorem in elementary set theory says that if you have an eq. rel on Y, then Y is the disjoint union of the corresponding eq. classes. If these are finite, they can of course be represented by a lists, but
    – Thomas
    Apr 21 '13 at 12:03
  • (ctd) you talk about testing -- what is it you want to test? And which is the requirement involving those colors you are talking about? And how are the developers you are mentioning are involved in all this?
    – Thomas
    Apr 21 '13 at 12:04

How can I use partitioning here? THis is actually taken from a book and it says that these sets are eq.classes.

I guess, the equivalence relation you are considering is defined in terms of the program flow as follows:

Given a program, we say that input data A and B are equivalent if the processing of A and B yields the same workflow in your program.

The same workflow means that the same procedures will be called and the same decisions will be made in the same order. (Most probably, we could express this by saying that the sequences of adresses that the instruction pointer visit when processing A agrees with the sequences resulting from the processing of B.)

In order to use paritioning, you consider all decisions made by the code you analyse and use these to find equivalence classes. Once you have these classes, pick any data in each class—this yields a system of representatives—and use this system of representatives to test your code.

  • this implies equivalence classes can only be used in whitebox testing which isn't true, you can also partition on output only for blackbox testing
    – jk.
    Jan 6 '14 at 13:51
  • @jk You are right! How could look a definition of the equivalence relation we use to partition the input data space?
    – user40989
    Jan 7 '14 at 15:19

Equivalence partitioning is pretty much grouping the list elements so that chosen colour is grouped to one group:


If you choose BLUE, then equivalence partitioning basically groups BLUE elements:


This can be represented as boolean sequence:

false,false,false, true,true,true,true, false, false

Now returning to the line intersection. If y=mx+c twice, then there is two pairs (x1,y1) and (x2,y2) so that they're the same element, i.e. x1=x2, y1=y2.

Each line has large number of (x,y) pairs which are not in the intersection, so you'll expect the following pattern:

false, false, false, false,..., false, true, false, false, false, ...

There is only one true value in the whole continuous sequence of (x,y) pairs.

  • Maybe the OP will get it but how did you came from RED, BLUE..to BLUE, BLUE, BLUE? What if my spec says that for BLUE, RED and YELLOW an action X will happen. Should I group them all as colors and test only one?
    – John V
    Apr 21 '13 at 14:14
  • user970696: x==BLUE||x==RED||x==YELLOW is a way to group several colours. Or use a range like [0..3].
    – tp1
    Apr 21 '13 at 15:54
  • The problem is that you cannot know if you can group them. The developer might have coded manually each of them and then you would need to test separately every different option. It is what book suggest: If the input conditions specify a set of values, identify a valid eq.class for each of them.
    – John V
    Apr 21 '13 at 16:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.