9

I want to write a test that calls a remote server and validates the response because the server may change (it's not under my control). To do this I figure I'd give it a tag (RemoteTest) and then exclude it when calling the runner:

sbt> test-only * -- -l RemoteTest

However, when doing this all my tests are run, including RemoteTest. How do I call the runner from within sbt so that it is excluded?

pr1001
  • 21,727
  • 17
  • 79
  • 125
  • While it doesn't answer to your question in any way, It is good practice to use stubs and [mocks](http://scalamock.org/) for such changing things. – om-nom-nom Apr 24 '12 at 17:40
  • I basically do. But I still want to know if the API changes on me. – pr1001 Apr 24 '12 at 18:06

1 Answers1

12

If you have the following:-

package com.test

import org.scalatest.FlatSpec
import org.scalatest.Tag

object SlowTest extends Tag("com.mycompany.tags.SlowTest")
object DbTest extends Tag("com.mycompany.tags.DbTest")

class TestSuite extends FlatSpec {

  "The Scala language" must "add correctly" taggedAs(SlowTest) in {
      val sum = 1 + 1
      assert(sum === 2)
    }

  it must "subtract correctly" taggedAs(SlowTest, DbTest) in {
    val diff = 4 - 1
    assert(diff === 3)
  }
}

To exclude DbTest tag, you would do:-

test-only * -- -l com.mycompany.tags.DbTest

Note that you'll need to include the full tag name. If it's still not working for you, would you mind sharing part of source code that's not working?

Chee Seng
  • 221
  • 2
  • 3