scala - How to access test/example/fragment name in Specs2 before and after methods? -


i like:

class myspec extends specification beforeafterexample {   var testname   var clientdir    def before {     testname = fragmentname.replaceall(" ", "-")     clientdir = new file(workspaceroot, testname)     clientdir.mkdirs()   }    def after {     fileutils.deletedirectory(clientdir)   } } 

this work:

class myspec extends specification beforeafterexample {   var currentexample = 0   var testname = ""   var clientdir:file = null    def before {     testname = is.examples(currentexample).desc.tostring.replaceall(" ", "-")     clientdir = new file(workspaceroot, testname)     clientdir.mkdirs()   }    def after {     fileutils.deletedirectory(clientdir)     currentexample += 1       } } 

i don't think can context in before , after methods without doing kind of hacky this.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -