Is there a way to have a tag that's excluded by default but I can include manually (for example with -n in SBT)?I'd like to have a tag called Slow. These tests would not be run by default with test or test-only. But I could enable them manually when I want those test to run.
I've tried in build.sbttestOptions in Test += Tests.Argument("-l", "Slow")which does exclude the tests by default. However, when I try to include them by runningsbt "testOnly -- -n Slow"
the Slow tests still don't run. Is this possible? Is there a better approach for this?
-n
and not mentioned in the tags to exclude, will be executed. --
You received this message because you are subscribed to the Google
Groups "scalatest-users" group.
To post to this group, send email to scalate...@googlegroups.com
To unsubscribe from this group, send email to
scalatest-use...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/scalatest-users?hl=en
ScalaTest itself, and documentation, is available here:
http://www.artima.com/scalatest
---
You received this message because you are subscribed to the Google Groups "scalatest-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalatest-use...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hi Bill,I didn't mean to imply it's behaving incorrectly. I appreciate the complexity of trying to fit many different use cases. I'm just curious whether there is a recommended way to get the behavior I'm looking for.
import org.scalatest._
import org.scalatest.tags.Slow
trait ExcludeSlowByDefault extends SuiteMixin with Suite {
override protected def runTests(testName: Option[String], args: Args): Status = {
val tagName = classOf[Slow].getCanonicalName
val filter = args.filter
val isExcluded = filter.tagsToExclude.contains(tagName)
val isIncluded = filter.tagsToInclude.isDefined && filter.tagsToInclude.get.contains(tagName)
if (!isExcluded && !isIncluded) {
val newFilter = Filter(filter.tagsToInclude, filter.tagsToExclude + tagName, filter.excludeNestedSuites, filter.dynaTags)
super.runTests(testName, args.copy(filter = newFilter))
} else {
super.runTests(testName, args)
}
}
}import org.scalatest._
import org.scalatest.tags.Slow
trait ExcludeSlowByDefault extends SuiteMixin with Suite {
override protected def runTests(testName: Option[String], args: Args): Status = {
val slowTagName = classOf[Slow].getCanonicalName
val selectedTagName = "org.scalatest.Selected" // couldn't find the actual class?
val filter = args.filter
val isExcluded = filter.tagsToExclude.contains(slowTagName)
val isIncluded = filter.tagsToInclude.isDefined && filter.tagsToInclude.get.contains(slowTagName)
val isSelected = filter.tagsToInclude.isDefined && filter.tagsToInclude.get.contains(selectedTagName)
val newTagsToExclude = if (!isExcluded && !isIncluded && !isSelected) {
filter.tagsToExclude + slowTagName
} else if (isExcluded) {
filter.tagsToExclude - slowTagName
} else {
filter.tagsToExclude
}
val newFilter = Filter(filter.tagsToInclude, newTagsToExclude, filter.excludeNestedSuites, filter.dynaTags)
super.runTests(testName, args.copy(filter = newFilter))
}
}