Test Driven Development

Thinking about Testing  Functions in terms of  Equivalence Partitions 


What is an equivalence partition, anyway? 


Simply put, it is the categorisation of inputs into values that would produce the same output for a given function. 

Let us understand with the help of an example, shall we?  🥸


def ( n ) : 

if n<1:

  return 'hi'

        return 'bye'


How many equivalence partitions does the aforementioned function have ? ? ? 🤔


If you guessed 2, you'd be right! 

---

Partition 1 : 

    All values that are less than 1  ( Eg : 0, -1 , -2 etc ) 


Partition 2 : 

   All values that are greater than or equal to 1  ( Eg : 1,2 ,3 etc )

---

So, all we need to be concerned about is testing those 2 categories of inputs. 


What's great about taking such an approach to testing, is that  it allows us to provide 100% coverage ( i.e 100 %  certainty ) that we're not leaving any edge case unhandled