scalatest在intellij 13.1中不起作用
我似乎无法让Intellij 13.1运行我的测试。 我已经创建了一个简单的项目来尝试隔离问题,但它也不适用于此。 这是我的设置:
这是主要的:
object Calc {
def add(a: Int, b: Int) = {
a + b
}
}
这是测试:
import org.scalatest.FunSuite
class Calc$Test extends FunSuite {
test("two number should add") {
assert(Calc.add(2, 5) == 7)
}
}
这是我得到的错误:
错误:scalac:编译时:/Users/test-user/Development/temp/sample/src/test/scala/Calc$Test.scala阶段:typer库版本:版本2.10.4编译器版本:版本2.10.4重构args:-nobootcp -javabootclasspath:-classpath /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/deploy.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents /Home/lib/dt.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/javaws.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents /Home/lib/jce.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/jconsole.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents /Home/lib/management-agent.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/plugin.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk /Contents/Home/lib/sa-jdi.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/charsets.jar:/System/Library/Java/Jav aVirtualMachines / 1.6.0.jdk /内容/班/ classes.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/jsse.jar:/System/Library/Java/JavaVirtualMachines/1.6。 0.jdk /内容/班/ ui.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/apple_provider.jar:/System/Library/Java/JavaVirtualMachines/1.6。 0.jdk /内容/首页/ lib / ext目录/ dnsns.jar:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/localedata.jar:/系统/库/ Java的/ JavaVirtualMachines / 1.6.0.jdk /内容/首页/ lib / ext目录/程序(sunjce_provider.jar):/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/ext/sunpkcs11.jar:/用户/测试用户/开发/温度/样品/目标/阶-2.10 /测试类:/Users/test-user/Development/temp/sample/target/scala-2.10/classes:/Users/test-user/.sbt /boot/scala-2.10.4/lib/scala-library.jar:/Users/test-user/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.11.2.jar :/Users/test-user/.ivy2/cache/org.scala-lang/scala-reflect/ja RS /斯卡拉 - 反射 - 2.11.2.jar:/Users/test-user/.ivy2/cache/org.scala-lang.modules/scala-xml_2.11/bundles/scala-xml_2.11-1.0.2。罐子:/Users/test-user/.ivy2/cache/org.scalatest/scalatest_2.11/bundles/scalatest_2.11-2.2.1.jar:/Users/test-user/.sbt/boot/scala-2.10。 4 / lib / scala-reflect.jar:/Users/test-user/.sbt/boot/scala-2.10.4/lib/scala-compiler.jar最后一棵树到typer:Apply(method ==)symbol:method = = class in Int(flags:)符号定义:def ==(x:Int):布尔值tpe:布尔符号所有者:方法== - >类Int - >包scala上下文所有者:值 - >类Calc $ Test - >包==包含模板或块==模板(// val:在类中Calc $ Test“FunSuite”//父母ValDef(private“_”)// 2语句DefDef(// def():Calc $ Test class Calc $ Test“”[] List(Nil)// tree.tpe = Calc $ Test Block(// tree.tpe = Unit Apply(// def():org.scalatest.FunSuite in class FunSuite,tree.tpe = org.scalatest.FunSuite在类FunSuite中,// def():org.scalatest.FunSuite,tree.tpe = ()org.scalatest.FunSuite Nil)()))Apply(“Apply”(“test”“two number should add”)Apply(“assert” ():Boolean.tpe = Boolean Calc.add(2,5)。“$ eq $ eq”// def ==(x:Int):类Int中的布尔值,tree.tpe =(x:Int)Boolean 7))) )==树的扩展类型== TypeRef(TypeSymbol(最终抽象类Boolean继承AnyVal))编译期间未捕获的异常:scala.MatchError
任何想法可能是什么问题? 我认为这是由简单的配置问题引起的,因为代码尽可能简单。
你明确的一个问题是你要求为Scala 2.11编译的scalatest版本,但你说你正在使用Scala 2.10。 您需要在您的build.sbt中使用“scalatest_2.10”而不是“scalatest_2.11”。 使用
libraryDependencies += "org.scalatest" % "scalatest_2.10" % "2.2.1" % "test"
或者甚至是
libraryDependencies += "org.scalatest" %% "scalatest" % "2.2.1" % "test"
以自动获取您的Scala版本(注意更改为双重百分比:%%。)
由于您的项目支持2.10,因此也使用相同版本的scalatest,
scalaVersion := "2.10.5" // don't need to mention scalatest_2.10, will be reflected automatically
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" // works with 2.2.1 or 3.0.0
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.0" % "test"
或者使用maven,
<dependency>
<groupId>org.scalactic</groupId>
<artifactId>scalactic_2.10</artifactId>
<version>3.0.0</version>
</dependency>
<dependency>
<groupId>org.scalatest</groupId>
<artifactId>scalatest_2.10</artifactId>
<version>3.0.0</version>
<scope>test</scope>
</dependency>
请参阅此处http://www.scalatest.org/install
链接地址: http://www.djcxy.com/p/62783.html