diff --git a/build.gradle b/build.gradle index ea68880b..d2072e50 100644 --- a/build.gradle +++ b/build.gradle @@ -50,7 +50,7 @@ subprojects { apply plugin: 'osgi' group = 'com.tngtech.junit.dataprovider' - version = '2.3' + version = '2.4-SNAPSHOT' tasks.withType(JavaCompile) { options.encoding = 'UTF-8' diff --git a/junit4/src/main/java/com/tngtech/java/junit/dataprovider/DataProviderFilter.java b/junit4/src/main/java/com/tngtech/java/junit/dataprovider/DataProviderFilter.java index 910011f5..59998553 100644 --- a/junit4/src/main/java/com/tngtech/java/junit/dataprovider/DataProviderFilter.java +++ b/junit4/src/main/java/com/tngtech/java/junit/dataprovider/DataProviderFilter.java @@ -61,8 +61,10 @@ public DataProviderFilter(Filter filter) { @Override public boolean shouldRun(Description description) { - Matcher filterDescriptionMatcher = DESCRIPTION_PATTERN.matcher(filter.describe()); - if (!filterDescriptionMatcher.find()) { + String filterDescription = filter.describe(); + + Matcher filterDescriptionMatcher = DESCRIPTION_PATTERN.matcher(filterDescription); + if (filterDescription.contains(" OR ") || !filterDescriptionMatcher.find()) { return filter.shouldRun(description); } String methodName = filterDescriptionMatcher.group(GROUP_METHOD_NAME); diff --git a/junit4/src/test/java/com/tngtech/java/junit/dataprovider/DataProviderFilterTest.java b/junit4/src/test/java/com/tngtech/java/junit/dataprovider/DataProviderFilterTest.java index 88f0af00..199dd476 100644 --- a/junit4/src/test/java/com/tngtech/java/junit/dataprovider/DataProviderFilterTest.java +++ b/junit4/src/test/java/com/tngtech/java/junit/dataprovider/DataProviderFilterTest.java @@ -71,6 +71,22 @@ public void testShouldRunShouldCallOriginalFilterShouldRunIfIsTestAndGivenDescri verifyNoMoreInteractions(filter); } + @Test + public void testShouldRunShouldCallOriginalFilterShouldRunIfGivenDescriptionContainsOr() { + // Given: + doReturn("Matching description Method failing1[0: 0](Test1) OR Method failing2[0: 0](Test2)").when(filter) + .describe(); + Description description = setupDescription(true, "failing1[0: 0](Test1)"); + + // When: + underTest.shouldRun(description); + + // Then: + verify(filter).describe(); + verify(filter).shouldRun(description); + verifyNoMoreInteractions(filter); + } + @Test public void testShouldRunShouldReturnFalseWhenDescriptionDoesNotHaveExpectedMethodName() { // Given: