I am using GebReportingSpec.
I want to get name of test that will be executed by using setup method.
I am get null output from testName.methodName
my code snippet is as below:
class CRMAppLoginSpec extends GebReportingSpec {
@Rule
public TestName testName = new TestName()
setup()
{
String methodName = testName.methodName;
println (methodName)
}
def "mytest"(String myName)
{
given: "This is my test case in geb-spock"
when: "capture the parameter"
def var1 = myName
then: "Display input parameter"
println ("Welcome to geb-spock : ${var1}" )
where:
myName << ["Debasish", "Prashant"]
}
You should probably start with code that runs.
Check out this answer about working with errors on each test, it will show you how to do something at each phase of the test lifecycle. Answer
If you are trying to improve console reporting it would be best to use Spock's AbstractRunListener. Check this out
You have iterations where each method name will be identical you could use the @Unroll annotation to differentiate between them.