Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams public void createNewContact1(String subject, String fName, String lName, String petname ) throws InterruptedException, AWTException ..... public void createNewContact2(String comp, String comPos, String dept, String conLookSup ) throws InterruptedException ..... public void createNewContact3(String conLookAss, String conLookRef ) throws InterruptedException .....

ContactsPageTest Class:-

public class ContactsPageTest extends TestBase {
TestUtil testUtil;
LoginPage loginpage;
HomePage homepage;
ContactsPage contactsPage;
String sheetName = "Contacts";
public ContactsPageTest() {
    super();
@BeforeMethod()
public void setUp() throws InterruptedException {
    initialzation();
    testUtil = new TestUtil();
    loginpage = new LoginPage();
    homepage = loginpage.login(prop.getProperty("username"), prop.getProperty("password"));
    contactsPage = new ContactsPage();
 * @Test(priority = 1) public void contactsLabelTest() throws
 * InterruptedException { testUtil.switchToFrame(); contactsPage =
 * homepage.contactsLink(); Thread.sleep(3000);
 * Assert.assertTrue(contactsPage.contactsLabel(), "Exception has caught!"); }
@DataProvider
public Object[][] getCRMTestData() {
    Object data[][] = TestUtil.getTestData("Contacts");
    return data;
@Test(priority = 2, dataProvider = "getCRMTestData")
public void createNewContactTest1(String subject, String fName, String lName, String petname)
        throws InterruptedException, AWTException {
    testUtil.switchToFrame();
    homepage.moveToNewContact();
    contactsPage.createNewContact1(subject, fName, lName, petname);
@Test(priority = 3, dataProvider = "getCRMTestData")
public void createNewContactTest2(String comp, String comPos, String dept, String conLookSup)
        throws InterruptedException, AWTException 
contactsPage.createNewContact2(comp, comPos, dept, conLookSup);
@Test(priority = 4, dataProvider = "getCRMTestData")
public void createNewContactTest3(String conLookAss, String conLookRef)
        throws InterruptedException, AWTException 
 contactsPage.createNewContact3(conLookAss, conLookRef);
@AfterMethod
public void close() {
    driver.close();

Error Message:

FAILED: createNewContactTest1
org.testng.internal.reflect.MethodMatcherException: 
Data provider mismatch
Method: createNewContactTest1([Parameter{index=0, type=java.lang.String, declaredAnnotations=[]}, Parameter{index=1, type=java.lang.String, declaredAnnotations=[]}, Parameter{index=2, type=java.lang.String, declaredAnnotations=[]}, Parameter{index=3, type=java.lang.String, declaredAnnotations=[]}])
Arguments: [(java.lang.String) Mr,(java.lang.String) Manideep,(java.lang.String) Latchupatula,(java.lang.String) Deep,(java.lang.String) Accenture,(java.lang.String) ASE,(java.lang.String) CSE,(java.lang.String) TL,(java.lang.String) NA,(java.lang.String) NA]
    at org.testng.internal.reflect.DataProviderMethodMatcher.getConformingArguments(DataProviderMethodMatcher.java:45)
    at org.testng.internal.Parameters.injectParameters(Parameters.java:796)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:982)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
    at org.testng.TestRunner.privateRun(TestRunner.java:648)
    at org.testng.TestRunner.run(TestRunner.java:505)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:455)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:450)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:415)
    at org.testng.SuiteRunner.run(SuiteRunner.java:364)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:84)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1208)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1137)
    at org.testng.TestNG.runSuites(TestNG.java:1049)
    at org.testng.TestNG.run(TestNG.java:1017)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

Description: I am working to develop Hybrid Framework by using Selenium. I started off on a positive note but I've been stuck at:

org.testng.internal.reflect.MethodMatcherException.

I have tried for some time but I am clueless. So here, I am.

Could you please let me know where the issue is?

It is throwing MethodMatcherException because you are passing same Data provider to different @Test Method, And Each test method has different Parameter value. Parameters return by @DataProvider and @Test Method should must match in order to retrieve and assign data.

You need to make sure what Data provider is returning, And you can assign it according those Parameters to Test method.

Here your Data Provider is returning Parameters as Following: Its 10 Parameter [Mr,Manideep,Latchupatula,Deep, Accenture, ASE, CSE,TL, NA,

And You are binding it with 4 Parameters of @Test createNewContactTest1 method:

createNewContactTest1(String subject, String fName, String lName, String petname)

You need to Manage

  • Your Data provider retrieval code as according to your required Parameters OR

  • You can create different sheet with required parameters OR

  • You can add all 10 Parameters to @Test method as according to DP returns

  • Thank you, @Ishita Shah, for your crystal clear explanation. Do we have another way to add parameters if we have more parameters? – Elegant Student Aug 21, 2018 at 11:51 Your way is correct. Just number of argument list is incorrect. As mentioned, You can manage it by any of three ways. And Simplest way for beginning is To create separate "Sheet" in excel as according to your required Parameters. – Ishita Shah Aug 21, 2018 at 11:54

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.