Can I declare somehow @BeforeMethod with Method and Object[] as params

45 views
Skip to first unread message

hridi

unread,
Jul 8, 2011, 8:15:22 AM7/8/11
to testng-users
Hi. When I declare my:
@BeforeMethod
void someMethod(Method test) { ... }
all is OK.

If I want to receive test's parameters, I can declare it:
@BeforeMethod
void someMethod(Object [] params) { .. }

But if I want both, it could not inject them.
If I declare it:

@BeforeMethod
void someMethod(Method test, Object [] params) { ... }

I receive:
FAILED CONFIGURATION:
java.lang.IllegalArgumentException: argument type mismatch
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:
25)
at java.lang.reflect.Method.invoke(Method.java:597)
at
org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:
76)
...
...


Any help appreciated.

TIA,
Hristo

Cédric Beust ♔

unread,
Jul 8, 2011, 1:39:37 PM7/8/11
to testng...@googlegroups.com
Hi Hristo,

I just fixed this in the beta:  http://testng.org/beta

If using the beta is not practical for you, you can just swap your parameters (Object[] first, then Method) and your code should work.

-- 
Cédric





--
You received this message because you are subscribed to the Google Groups "testng-users" group.
To post to this group, send email to testng...@googlegroups.com.
To unsubscribe from this group, send email to testng-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/testng-users?hl=en.


Reply all
Reply to author
Forward
0 new messages