我正在尝试在Intellij IDEA(最新的社区版,带有最新的Scala插件)中运行Scala Flatspec测试,但是一直遇到“空测试套件”错误。
我尝试使用正常的右键“运行”菜单,但无效。我还尝试创建一个新的ScalaTest配置,但仍然无法找到测试。
我能够使用带有unit的JScalaTest,但我真的更喜欢使用Flatspec语法。
更新:为类添加@RunWith(classOf[JUnitRunner])
注释也没有帮助。
谢谢!
class SampleTestSpec extends FlatSpec with ShouldMatchers {
"test" should "fail" in {
"this" should equal ("that")
}
}
更新:切换到Spec,问题解决了。我仍然更喜欢使用FlatSpec的ScalaTest,但这已经足够好了。可以运行的代码:
import org.specs._
object SampleTestSpec extends Specification {
"'hello world' has 11 characters" in {
"hello world".size must be equalTo(113)
}
"'hello world' matches 'h.* w.*'" in {
"hello world" must be matching("h.* w.*")
}
}
-teo