[TIP] Interface vs Implementation Testing

Raphael Marvie raphael.marvie at lifl.fr
Mon Apr 16 10:51:58 PDT 2007


Dear all,

I have a queue of request providing the functions: add(request),  
delete(request), list(), next(), and destroy(). I am implementing  
using TDD, so tests are written before implementation. Then, would  
you favour tests to be interface-based or implementation-based?

As a first implementation the queue persistency is to be managed  
using the file system (a folder for the queue, a file per request -- 
containing the request details). But, another implementation may be  
chosen later on, so tests should be re-usable.

Would you:

  a. write interface-based tests and implementation specific ones  
(the first ones could then be re-used later on),

  b. write interface-based tests only (but you cannot completely be  
sure your implementation works fine),

  c. write implementation-specific tests only (they cannot be re- 
used, but no one know if this will be necessary, and you will have  
confidence in your implementation),

  d. do something completely different?

If you have chosen a., would you:

  1. write interface-based tests as doctests in the module itself,  
and write unittest ones for the implementation specific part,

  2. write a test case class for the interface-based tests and  
extends this class for the implementation specific ones (as many  
times as necessary)?

Thanks for your feelings on this kind of how to test choice.

r.

ps for the moment, I would say a.1 in python and a.2 in Java.

--
Raphael Marvie, PhD                http://www.lifl.fr/~marvie/
Maître de Conférences / Associate Professor  @  LIFL -- IRCICA
Directeur du Master Informatique Professionnel spécialité IAGL
Head of Master's in Software Engineering     +33 3 28 77 85 83





More information about the testing-in-python mailing list