1.

Should Unit-tests Touch The Database Or Anything Out-of-process?

Answer»

In my opinion, yes. I realize that there are many who disagree with me on this point, but the fact remains that you cannot test an OBJECT which has a primary function of loading data from (or saving data to) a database without checking if it in fact, LOADS (or saves) said data correctly. The most important boundary not to cross in our unit tests is the one between application layers. Don't test the database logic with the business logic; each of these layers should be tested in isolation. For a more detailed explanation, see Unit Testing the Data TIER that I WROTE more than 4 YEARS ago. While some of the technologies described have changed since that article, the fundamental idea has not.

In my opinion, yes. I realize that there are many who disagree with me on this point, but the fact remains that you cannot test an object which has a primary function of loading data from (or saving data to) a database without checking if it in fact, loads (or saves) said data correctly. The most important boundary not to cross in our unit tests is the one between application layers. Don't test the database logic with the business logic; each of these layers should be tested in isolation. For a more detailed explanation, see Unit Testing the Data Tier that I wrote more than 4 years ago. While some of the technologies described have changed since that article, the fundamental idea has not.



Discussion

No Comment Found