DefaultDataProviderMethodResolver implements DataProviderMethodResolver { protected boolean isMatchingNameConvention(String testMethodName, String dataProviderMethodName) { if (dataProviderMethodName.equals(testMethodName)) { return true; } else if (dataProviderMethodName.equals(testMethodName.replaceAll("^test", "dataProvider"))) { return true; } else if (dataProviderMethodName.equals(testMethodName.replaceAll("^test", "data"))) { return true; } else if (dataProviderMethodName .equals("dataProvider" + toUpperCase(testMethodName.charAt(0)) + testMethodName.substring(1))) { return true; } else if (dataProviderMethodName .equals("data" + toUpperCase(testMethodName.charAt(0)) + testMethodName.substring(1))) { return true; } return false; }  @Override List<Method> resolve(DataProviderResolverContext context);  }
@Test public void testIsMatchingNameConventionShouldReturnFalseForNamesNotStickToSupportedConventions() { final String testMethodName = "testMethod"; final String dataProviderMethodName = "notMatchingDataProviderMethod"; boolean result = underTest.isMatchingNameConvention(testMethodName, dataProviderMethodName); assertThat(result).isFalse(); }
@Test public void testIsMatchingNameConventionShouldReturnTrueIfDataProviderMethodHavingSameNameAsTestMethod() { final String testMethodName = "testMethod"; boolean result = underTest.isMatchingNameConvention(testMethodName, testMethodName); assertThat(result).isTrue(); }
@Test public void testIsMatchingNameConventionShouldReturnTrueIfDataProviderMethodHavingDataProviderPrefixInsteadOfTest() { final String testMethodName = "testMethod"; final String dataProviderMethodName = "dataProviderMethod"; boolean result = underTest.isMatchingNameConvention(testMethodName, dataProviderMethodName); assertThat(result).isTrue(); }
@Test public void testIsMatchingNameConventionShouldReturnTrueIfDataProviderMethodHavingDataPrefixInsteadOfTest() { final String testMethodName = "testMethod"; final String dataProviderMethodName = "dataMethod"; boolean result = underTest.isMatchingNameConvention(testMethodName, dataProviderMethodName); assertThat(result).isTrue(); }
@Test public void testIsMatchingNameConventionShouldReturnTrueIfDataProviderMethodHavingDataProviderPrefix() { final String testMethodName = "testMethod"; final String dataProviderMethodName = "dataProviderTestMethod"; boolean result = underTest.isMatchingNameConvention(testMethodName, dataProviderMethodName); assertThat(result).isTrue(); }
@Test public void testIsMatchingNameConventionShouldReturnTrueIfDataProviderMethodHavingDataPrefix() { final String testMethodName = "testMethod"; final String dataProviderMethodName = "dataTestMethod"; boolean result = underTest.isMatchingNameConvention(testMethodName, dataProviderMethodName); assertThat(result).isTrue(); }