ScalaTest test exception when calling my tests from sbt

I want to write a test that calls a remote server and checks the answer because the server may change (it is not under my control). To do this, I suppose to give it a tag ( RemoteTest ), and then exclude it when calling the runner :

 sbt> test-only * -- -l RemoteTest 

However, when executed, all my tests run, including RemoteTest . How do I name a runner from within sbt so that it is excluded?

+8
scala sbt scalatest
source share
1 answer

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 the DbTest tag, you must: -

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

Please note that you will need to provide the full name of the tag. If it still does not work for you, could you share a piece of source code that does not work?

+10
source share

All Articles