Created
February 15, 2018 16:42
-
-
Save zawadz88/810ba3137a18411dd4ad82b77c3b1f6b to your computer and use it in GitHub Desktop.
Parent filter copied from Android Support test library
This file contains hidden or 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
| package com.stepstone.base.test.runner.filter | |
| import org.junit.runner.Description | |
| import org.junit.runner.manipulation.Filter | |
| /** | |
| * Helper parent class for [Filter] that allows suites to run if any child matches. | |
| */ | |
| abstract class ParentFilter : Filter() { | |
| /** | |
| * {@inheritDoc} | |
| */ | |
| override fun shouldRun(description: Description): Boolean { | |
| if (description.isTest) { | |
| return evaluateTest(description) | |
| } | |
| // this is a suite, explicitly check if any children should run | |
| // no children to run, filter this out | |
| return description.children.any { shouldRun(it) } | |
| } | |
| /** | |
| * Determine if given test description matches filter. | |
| * | |
| * @param description the [Description] describing the test | |
| * @return `true` if matched | |
| */ | |
| protected abstract fun evaluateTest(description: Description): Boolean | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment