lundi 6 août 2018

Test file structure in groovy(Spock)

How to test created and expected file tree in groovy(Spock)? Right now I'm using Set where I specify paths which I expect to get and collecting actual paths in this way:

Set<String> getCreatedFilePaths(String root) {
    Set<String> createFilePaths = new HashSet<>()
    new File(root).eachFileRecurse {
        createFilePaths << it.absolutePath
    }
    return createFilePaths
}

But the readability of the test isn't so good. Is it possible in groovy to write expected paths as a tree, and after that compare with actual

For example, expected:

region:
     usa:
       new_york.json
       california.json
  europe:
       spain.json
       italy.json

And actual will be converted to this kind of tree.

Aucun commentaire:

Enregistrer un commentaire