V
V
velvetcat2014-08-13 21:27:49
Behavior-driven development
velvetcat, 2014-08-13 21:27:49

Is it possible to check what the model has written to the database using the model itself?

I'm developing through testing a model ( Queue ), and in particular its queue.add (item) method . Test structure:
- clear the database
- call queue.add(item)
- make sure that the item is in the database.
There are two options for the first and last items:
a) clear the table manually, check also with a direct request
b) clear the queue using the queue.clear() method, check using the queue.find() method.
The first one looks more thorough, but is much more complex and generates duplication between code and test. The second one is not clear what it is testing and relies on methods that don't exist yet, but is much more concise and less brittle.
What is the conceptual difference between these two ways? Or maybe there is another option? What to choose and in what situation? 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