我已更新我的问题,删除旧文本,使其更容易阅读。斯卡拉spec2 object.productID必须_ ==“123”失败
scalaVersion := "2.10.1"
"org.specs2" %% "specs2" % "1.13" % "test"
我SPEC2测试:
package com.mycompany.dataminer.parser
import org.specs2.mutable.Specification
case class Product(productID:String)
class SimpleTest extends Specification {
"product" should {
"have id = 123" in {
var product1 = Product("123")
product1 must not beNull
product1.productID must_== "123"
var product2 = Product("123")
product2 must not beNull
product2.productID must_== "123"
var product3 = Product("123")
product3 must not beNull
product3.productID must_== "123"
}
}
}
结果:
scala: type mismatch;
found : String
required: org.specs2.matcher.Matcher[com.mycompany.dataminer.parser.Product]
product1.productID must_== "123"
^
有一次,我写了这个代码,这是工作,直到我添加此行:
product1 must not beNull
product2 must not beNull
product3 must not beNull
我已将此问题发布到spec2问题跟踪器(为了不忘记:)) – ses 2013-04-28 22:46:46