There are several methods for dealing with this one is the use of a common initializations class that setup the basic structure and adds basic data needed for the tests. The problem with this approach is that if you need to add some new data or change data in the setup you will have a huge impact on the tests and maybe changing a few that should have given indications on a problem that has been introduced. Its often better to separate the tests and let each test setup the data required for just that test and clean up afterwards. If using a database the setup and teardown of the database could be a common setup that is run first in the testclass and teardown occured at the end after all tests. In such an instance you need a way to clean out the database without tearing it down compleatly.
Of course these are just my thoughts and there a several methods in dealing with this. One that we often use is the use of mocking of objects since you then don't need a real database just the apperance of one. from the systems point of view. This makes that test much much more efficient and faster but has the drawback that you aren't really testing the database which also needs to be done.
I any circumstance test ARE important and you should never feel that a test is useless and remove them if you aren't compleatly and absolutly sure since there is often a very good reason for that the test was created in the first place.
Happy testing!
No comments:
Post a Comment