Unit testing 如何使用JUnit4运行scala测试?
我无法使用IDEA运行以下代码Unit testing 如何使用JUnit4运行scala测试?,unit-testing,scala,scala-2.8,junit4,Unit Testing,Scala,Scala 2.8,Junit4,我无法使用IDEA运行以下代码 @Test class CompanyURLTest extends Assert { @Test def test = assert(false); } 它可以运行,但是J-Unit说没有要运行的测试 import org.junit._ import Assert._ class MyTest { @Test def test = assert(false) } 以下是我的作品 import org.junit._ impor
@Test
class CompanyURLTest extends Assert {
@Test
def test = assert(false);
}
它可以运行,但是J-Unit说没有要运行的测试
import org.junit._
import Assert._
class MyTest {
@Test
def test = assert(false)
}
以下是我的作品
import org.junit._
import Assert._
class MyTest {
@Test
def test = assert(false)
}
@org.junit.Test注释仅适用于方法:@Target({ElementType.METHOD})。 还要记住,测试方法必须返回单元
import org.junit.Assert._
import org.junit.Test
class CompanyURLTest {
@Test def test = assertFalse(false)
}
@org.junit.Test注释仅适用于方法:@Target({ElementType.METHOD})。 还要记住,测试方法必须返回单元
import org.junit.Assert._
import org.junit.Test
class CompanyURLTest {
@Test def test = assertFalse(false)
}
我通常将ScalaTest与Junit4 runner结合使用,以便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)
}
}
ScalaTest文档位于我通常将ScalaTest与Junit4 runner结合使用,以便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)
}
}
ScalateTest文档位于,尽管它是后期版本,但令人惊讶的是,该网站有很多优秀的教程,展示了如何支持Scala测试
尽管是晚年,但令人惊讶的是,该网站有很多优秀的教程,展示了如何支持Scala测试
您能详细介绍一下您正在使用的测试框架吗?它是纯JUnit还是与之一起使用的其他东西?您能告诉我们更多关于您正在使用的测试框架的信息吗?它是纯JUnit还是其他什么东西?