L
L
Lesha Kiselev2014-06-03 13:07:34
Theory
Lesha Kiselev, 2014-06-03 13:07:34

What should unit tests cover?

My question is:
How to correctly write Unit tests? What exactly should they cover?
This is more of a theoretical question than a practical one.
Let's say I have some kind of interface that implies that the class that implements it will write/read to/from storage and perform some data manipulation (for example, wrap it in another interface and return it). For interface tests, I chose to store data in memory. Covered with tests.

EntityInterface: 
    getDataFieldValue : void
    setDataFieldValue : mixed 
    getScheme : SchemeInterface

The SchemeInterface test implementation also keeps some data in memory.
In production, interface implementations store data in MySQL .
Now the main question is:
How many test suites will it take to write if I need to create an implementation of interfaces that store data in Redis ?
According to my calculations it turns out:
  1. Test suite for EntityInterface
  2. Test suite for SchemeInterface
  3. Test suite for EntityMysqlStorage
  4. Test suite for SchemeMysqlStorage
  5. Test suite for EntityRedisStorage
  6. Test suite for SchemeRedisStorage

Is this true?
Or is only the first two sets sufficient?
And in general, am I on the right track?
Thank you.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question