Alex Luya
Alex Luya

Reputation: 9922

Can't add multiple annotations on a groovy method?

 when I add two annotations to a method like this       

@Parameters({"userName",""})
@Test
public void replyMaster()
{

}

got this error

 Multiple markers at this line
- Groovy:unexpected token: @ @ line 40, column 2.
- Duplicate field ReplyTest.@
- Groovy:The field '@' is declared multiple times.

my configuration:jdk 1.7,testng 6.8,groovy 2.0(installed with groovy eclipse plugin)

why?

Upvotes: 5

Views: 2379

Answers (1)

tim_yates
tim_yates

Reputation: 171114

If this is a Groovy file, then

@Parameters({"userName",""})

Should probably be:

@Parameters(["userName",""])

Or

@Parameters(["userName",""] as Object[])

Not sure, I haven't used TestNG. But you can definitely have multiple annotations per node with Groovy, it's just this isn't how groovy does lists or arrays

Upvotes: 15

Related Questions