image - Test for created file with Spock in Gradle -


I have a job that produces a picture, so I want to write a test for this comparison of this image binary < em> the first picture Resources has been generated in the folder

  def setupSpec () {project = ProjectBuilder.builder (). Hopefully Build () GenericPicTask = project.tasks.create (SomePlugin.GENERATE_PIC_TASK_NAME, GeneratePicTask)} def 'picture Test Create () {When the file filename = new File ( "Information") Then Generate PicTask.createPicture (fileName) FileName.exists () == true}  

but there is an error that

  c: \ user \ user \ apeda \ local \ temp \ gradle1393280218367058727projectDir \ build \ Info.PNG (system specified can not find the path)  

working drawings generatePicTask to stop action Generate

Project object is a dummy project so I do not know that it was also executed. How can I fix this?

I see 3 problems from your current perspective:

Your test current Do not trust working directory So instead of creating a file like this:

  file filename = new file ("info")  

For example, use a junit TemporaryFolder rule . For more information on how to provide access

It seems that generate generated Krenpik Task Work 'Build' directory does not have the

Make sure that the output directory (manufactured original image Folder exists) You can use the sad annotation example @Output directory should be kept in mind that take care of it. Otherwise something like 'fileName.parentfile.mkdirs' before making your image

way normally going to divide the configuration of their work and performance:

  GenericPicTask.setPicture (fileName) GenericPicTask.create () // Your @TaskAction annotated method  

Cheers, René


Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -