如何使用junit 4运行scala测试?

yur*_*ura 1 unit-testing scala junit4 scala-2.8

我无法使用IDEA运行以下代码

@Test
class CompanyURLTest extends Assert {
  @Test
  def test = assert(false);

}
Run Code Online (Sandbox Code Playgroud)

它运行,但J-Unit表示没有测试运行

Age*_*oij 5

我通常将ScalaTest与Junit4运行器结合使用,以便Maven查看并执行我的测试.我喜欢用于组织测试的Spec/FlatSpec/WordSpec语义.我正在尝试使用ShouldMatchers,但我已经使用了JUnit这么长时间,断言对我来说似乎更自然一些.

这是一个例子:

import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.FlatSpec
import org.scalatest.matchers.ShouldMatchers

@RunWith(classOf[JUnitRunner])
class BlogFeedHandlerTest extends FlatSpec with ShouldMatchers with Logging {
    "the thingy" should "do what I expect it to do" in {
        val someValue = false;

        assert(someValue === false)
    }
}
Run Code Online (Sandbox Code Playgroud)

ScalaTest文档位于http://www.scalatest.org/