简体   繁体   中英

can we Pass MethodName In TestNG DataProviders

I want to use one class from different package in different package where Dataprovider method is using.

Eg

My First Package name is: Framework Utilities

My Second Package name is: Framework Testcases

I want to use @DataProvider for Framework Testcases package but for that i want to use method which is available in the Framework Utilities package.

Can you please help me for the solution as it is very important

Dataprovider takes Method as an argument, which you can use to get package and other info. So you can declare it on the declaration and use to do your conditional checks.

eg.

@DataProvider(name = "testDataProvider2")
    public Object[][] testDataProvider2(Method method) {
        System.out.println(method.getDeclaringClass());...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM