I have an application which adds, deletes and retreives information (ex. person) from a text file.
I have created unit-tests in order to test the functionality of my code and have a lot of coverage. But I cannot agree if these tests are properly done for a SUT.
For example, to test addPerson, I create a person, add them to the text file, assert that they have been added, and then remove the person from the text file. I do not believe that this is correct because I do not think that tests should interact with the database. I have used similar methods to extract data from persons and delete persons as well.
But unfortunatly I cannot seem to agree if these tests should be either mocked, stubbed or left as is?
A source I have found says that https://thoughtbot.com/blog/don-t-stub-the-system-under-test SUT's should not be mocked, stubbed or spied.
From what I have understood is that mocks should only be used on Depended-On components.
Its a confusing topic as I have found a lot of opinions but not concrete information.
Aucun commentaire:
Enregistrer un commentaire