lundi 13 mai 2019

Should unit tests tests the functionality of a method?

I am writing unit tests but the part that confuses me most is whether it should test the functionality or not?

For example, if there is a method which does two things

  1. Deletes files from a folder
  2. Returns whether the folder is empty or not
public bool DeleteFTPFiles(string xyz)
{
    ...

    path = GetFTPPath(xyz);
    DeleteFolderFiles(path);
    return IsFtpFolderEmpty(path);
}

DeleteFolderFiles - deletes files based on some logic.

Now, if I have to do unit testing for this method(DeleteFTPFiles). Do I have to create folder structure and add some files through my unit tests as an Arrange test?

Assert whether files are deleted based on the condition?

Also, test if IsFtpFolderEmpty returns true or false based on whether it is empty or not?

If so, how is this different from Integration tests?

Aucun commentaire:

Enregistrer un commentaire