ohnosequences / nice-sbt-settings

sbt plugin with common settings for all era7/ohnosequences releases
GNU Affero General Public License v3.0
10 stars 2 forks source link

Release-only tests #37

Closed eparejatobes closed 8 years ago

eparejatobes commented 9 years ago

We frequently have the need for tests that create resources, perform expensive (time and money) operations etc. It would good to be able to mark those tests as "release-only", making sure that they will be run when (and only when) you are making a release.

I'm guessing this could be done using scalatest tags

and redefining sbt test so that normally it would exclude "release-only" tests. Found this about it:

laughedelic commented 9 years ago

Related in sbt-0.13.9:

Supports excluding tests in testOnly/testQuick with -, for example -MySpec.

laughedelic commented 9 years ago

By the way, the list of fixes in 0.13.9 looks good: https://github.com/sbt/sbt/releases/tag/v0.13.9

laughedelic commented 9 years ago
eparejatobes commented 8 years ago

We need this ASAP. A simple approach:

Tag for release-only tests

As in

package ohnosequences.tests
import org.scalatest.Tag
// NOTE use the String inside the Tag constructor later
case object releaseOnly extends Tag("ohnosequences.tests.tags.releaseOnly")

This is used like so

import ohnosequences.tests._

class FunnyTests extends FunSuite {

  test("launch 100 machines, do stuff", releaseOnly) {
    // ...
  }
}

Ignore that tag by default

In build.sbt or as part of this plugin (much better)

testOptions in Test += Tests.Argument("-l", "ohnosequences.tests.tags.releaseOnly")

Run them in the release task

Through some sbt magic that I don't quite understand. I guess it is possible to change the value of a setting temporarily right?

References
laughedelic commented 8 years ago

Good! Yes, it's doable 👍 I can spend some time on it this weekend

laughedelic commented 8 years ago

This is finally done:

Not the best solution, because testAll is defined through testOnly and this tag is excluded only from the test task. The other solution I have is through an sbt "configuration" scoping, but I didn't find how to add custom configs from a plugin.

laughedelic commented 8 years ago

I found a way to add configs with plugins. But I will change here all things to AutoPlugins first.