java - JUnit for a directory zipper -
java - JUnit for a directory zipper -
i have piece of code in java zips contents of directory zip file.
the signature of method follows:
/** * zips contents of directory zip file. * @param directory directory zip * @param zipfilename file name zip */ public static void dozip(string directory, string zipfilename) { //do zipping } now have write junit test case above method. should test, , how?
note : not looking answers on how write junit test case.
thanks in advance.
create temporary directory , write files directory. phone call method temp directory argument , given zip file name. test zip file exists. test can open zipfile , find expected zip entries in zip file.
the method doesn't specify contract well. example, doesn't if directory doesn't exist, or if it's impossible write zip file, it's hard test these aspects. normally, it's developer of method writes unit test it, because knows corner-cases are.
java junit
Comments
Post a Comment