spock - Grails java.io.File mocking -


is there way mock file unit testing in grails?

i need test file size , file type , if mock these.

any link resource help.

you can mock java.io.file in groovy code spock.

here's example of how it:

import spock.lang.specification  class filespyspec extends specification {     def 'file spy example' () {         given:         def mockfile = mock(file)         groovyspy(file, global: true, useobjenesis: true)         when:         def file = new file('testdir', 'testfile')         file.delete()         :         1 * new file('testdir','testfile') >> { mockfile }         1 * mockfile.delete()     } } 

the idea return file's spock mock java.io.file constructor call expectation has expected parameters.


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -