mercredi 25 février 2015

Grails spock Testing with File class

I have a method that create a file based in a content copied from an another file. Like below



private cloneBaseFile(fileName, ddi, ddd){


def config = grailsApplication.config.kicksim.fileConstants


String baseFileContents = new File(config.baseFile).getText('UTF-8')

def help = handleString("${ddd}.${ddi}")

baseFileContents = baseFileContents.replaceAll("DDDDDI", help);

def f1= new File(fileName)
f1 << baseFileContents

return fileName
}


I'd like to know how to unit test it.


Aucun commentaire:

Enregistrer un commentaire