-
-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #908 from MarathonLabs/feature/simple-testname-filter
feat(core): add simple-test-name filter
- Loading branch information
Showing
8 changed files
with
116 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
core/src/main/kotlin/com/malinskiy/marathon/execution/filter/SimpleTestnameFilter.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.malinskiy.marathon.execution.filter | ||
|
||
import com.malinskiy.marathon.config.TestFilterConfiguration | ||
import com.malinskiy.marathon.test.toSimpleSafeTestName | ||
|
||
class SimpleTestnameFilter(cnf: TestFilterConfiguration.SimpleTestnameFilterConfiguration) : | ||
SingleValueTestFilter(cnf.regex, cnf.values, cnf.file, { test, values -> | ||
val simpleSafeTestName = test.toSimpleSafeTestName(methodSeparator = '#') | ||
(regex?.matches(simpleSafeTestName) ?: true) && (values?.contains(simpleSafeTestName) ?: true) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
core/src/test/kotlin/com/malinskiy/marathon/execution/filter/SimpleTestnameFilterTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.malinskiy.marathon.execution.filter | ||
|
||
import com.malinskiy.marathon.config.TestFilterConfiguration | ||
import com.malinskiy.marathon.extension.toTestFilter | ||
import org.amshove.kluent.shouldBeEqualTo | ||
import org.junit.jupiter.api.Test | ||
import com.malinskiy.marathon.test.Test as MarathonTest | ||
|
||
class SimpleTestnameFilterTest { | ||
private val test1 = MarathonTest("com.example", "Test", "test1", emptyList()) | ||
private val test2 = MarathonTest("com.example.subpackage", "Test2", "test2", emptyList()) | ||
private val test3 = MarathonTest("com.sample", "Test3", "test3", emptyList()) | ||
private val test4 = MarathonTest("", "Test4", "test1", emptyList()) | ||
|
||
private val filter = | ||
TestFilterConfiguration.SimpleTestnameFilterConfiguration(values = listOf("Test2#test2")).toTestFilter() | ||
val tests = listOf( | ||
test1, | ||
test2, | ||
test3, | ||
test4 | ||
) | ||
|
||
@Test | ||
fun shouldFilter() { | ||
filter.filter(tests) shouldBeEqualTo listOf(test2) | ||
} | ||
|
||
@Test | ||
fun shouldNotFilter() { | ||
filter.filterNot(tests) shouldBeEqualTo listOf(test1, test3, test4) | ||
} | ||
|
||
@Test | ||
fun shouldFilterWithRegex() { | ||
TestFilterConfiguration.SimpleTestnameFilterConfiguration( | ||
regex = ".+test3".toRegex() | ||
).toTestFilter().filter(tests) shouldBeEqualTo listOf(test3) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters