Created
December 14, 2013 07:35
-
-
Save bvenners/7956533 to your computer and use it in GitHub Desktop.
One way to group tags in ScalaTest 2.0
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
import org.scalatest._ | |
trait TagGroups extends SuiteMixin { this: Suite => | |
private val groups: Map[String, Set[String]] = | |
Map( | |
"NonUnit" -> Set("org.scalatest.tags.Disk", "org.scalatest.tags.Network"), | |
"Sluggish" -> Set("org.scalatest.tags.Slow", "org.scalatest.tags.Network") | |
) | |
abstract override def run(testName: Option[String], args: Args): Status = { | |
def expandGroups(set: Set[String]): Set[String] = | |
set flatMap { tag => groups.getOrElse(tag, Set(tag)) } | |
val newTagsToInclude: Option[Set[String]] = | |
for (set <- args.filter.tagsToInclude) yield expandGroups(set) | |
val newTagsToExclude: Set[String] = expandGroups(args.filter.tagsToExclude) | |
val newFilter: Filter = | |
Filter( | |
newTagsToInclude, | |
newTagsToExclude, | |
args.filter.excludeNestedSuites, | |
args.filter.dynaTags | |
) | |
super.run(testName, args.copy(filter = newFilter)) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment