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
Post a Comment