In my grails integration test, how do I get the the currently executing test name?
I want to do this for logging purposes.
In my grails integration test, how do I get the the currently executing test name?
I want to do this for logging purposes.
Use JUnit's @Rule TestName
. This works with old style JUnit tests and spock specs.
Example:
import spock.lang.Specification
import org.junit.Rule
import org.junit.rules.TestName
class MyTestSpec extends Specification {
@Rule TestName name = new TestName()
void "test something"() {
setup:
println "running $name.methodName"
....
}
}