TestNG: How to call methods from 2 different class & 2 different packages using @test annotation

Screenshot%20(6) Screenshot%20(7)

Hi Folks,

I have 2 packages com.shutapp.createsession & com.shutapp.onboarding with respect to 2 classes Appium server and AddPhoneNumber.

Question is:

1.I dont want to call AndroidDriver<AndroidElement> driver = Capabilities(); in every class it executing twice with other methods MobileNumber() method but with out this driver reference cant write test cases

2.Even after giving @Test annotation it is not executing from another packages class

3.Please help me.

Try using testng.xml file check the doc

you can have something like this

< suite name = "Suite1" verbose = "1" >
< test name = "testName" >
< classes >
< class name = "com.shutapp.createsession" />
< class name = "com.shutapp.onboarding" />
</ classes >
</ test >
</ suite >

Hi chouaib ,

Thanks for the response at earliest.

But i have tried this , not executing com.shutapp.onboarding package having AddPhoneNumber class.
Can you check my java code and help me.

Thanks in Advance