#1 India's Top IT Training Institute
×

About Uncodemy

Know more about who we are and what we stand for.

About Us

About Us

Discover our mission to equip individuals with essential IT skills and industry expertise.

Read More →
UnCodeMy Gallery

UnCodeMy Gallery

Explore highlights from our IT training sessions and success stories.

Read More →
Mentors

Mentors

Meet the industry experts who train and guide you through your course.

Read More →
Free Resources

Free Resources

Free tutorials, interview questions, tools and calculators to help you learn.

Explore →
×

Free Resources

Learn, practice and plan your career — bilkul free.

Tutorials

Tutorials

Step-by-step written tutorials to learn any technology at your own pace.

Read More →
Free Counselling

Free Counselling

Book a free video counselling session and pick the right course for you.

Read More →
Online Compiler

Online Compiler

Write, run and test your code online — no setup required.

Read More →
Black Box Techniques

ECP (Equivalence Class Partitioning)

What is Equivalence Class Partitioning?

Equivalence Class Partitioning (ECP) is a black box test design technique that divides input data into partitions (classes) that are expected to be treated the same way by the system.

How ECP Works

  • Inputs are grouped into valid and invalid equivalence classes.
  • Only one representative value from each class needs to be tested, since all values in the class are assumed to behave similarly.

For example, for an input field accepting ages 18–60, the equivalence classes would be: less than 18 (invalid), 18–60 (valid), and greater than 60 (invalid).

Why ECP is Effective

ECP reduces the total number of test cases needed while still achieving reasonable coverage, since it avoids redundant testing of values that would behave identically. It is often used together with BVA for more complete coverage.

Partitioning a Form With Several Fields

Real screens rarely have just one input. Consider a mobile recharge form with three rules: the mobile number must be 10 digits, the operator must be chosen from a list, and the amount must be between 10 and 5,000.

FieldValid classesInvalid classes
Mobile numberV1: exactly 10 digitsI1: fewer than 10 digits, I2: more than 10 digits, I3: contains letters or symbols, I4: empty
OperatorV2: any operator in the listI5: nothing selected
AmountV3: 10 to 5,000I6: below 10, I7: above 5,000, I8: not a number, I9: decimal where only whole numbers allowed

Labelling every class with an ID makes coverage easy to check later, because each test case can list the IDs it covers.

The One-Invalid-Class-Per-Test Rule

Valid classes can be combined freely, so a single test like "9876543210, any listed operator, 199" covers V1, V2 and V3 together. Invalid classes should be tested one at a time, with every other field kept valid.

The reason is masking. If one test uses a 9-digit number and an amount of 6,000, the form might stop at the first error and never check the amount. The test would pass, yet the amount validation remains untested. So the invalid classes above need nine separate tests, I1 to I9, each with only one wrong field.

Partitions Beyond Number Ranges

Equivalence classes are not only about numeric ranges. Thinking more broadly finds tests that pure range thinking misses:

  • Sets of values: for a file upload accepting PDF and JPG, the classes are allowed types, other types, and files with a misleading extension.
  • Formats: an email field has well-formed addresses, missing @, missing domain, and spaces inside.
  • Must-be conditions: "the first character must be a letter" gives two classes: starts with a letter, starts with anything else.
  • Output classes: a shipping calculator might produce free shipping, standard charge, or a "cannot deliver" message. Choose inputs that produce each output at least once.
  • User or system states: logged-in, guest, and session-expired users may each form a class.

Where ECP Goes Wrong

  • Wrong assumptions about "same behaviour". If the system applies a different tax above a certain amount, the valid range is really two classes. Read the business rules, not just the field validation.
  • Skipping the empty input. Blank is often its own class with its own error message.
  • Picking edge values as representatives. ECP representatives should come from the middle of a class; edges belong to boundary value analysis, which then adds those tests separately.

Practical routine: list every input and output, write valid and invalid classes with IDs, design one test that covers as many valid classes as possible, add one test per invalid class, then layer boundary tests on any class with a numeric or length range.

Ready to master real-world software testing?

Learn manual and automation testing hands-on with mentor-led sessions.

Explore Course