Scala specs2 None不等于None

时间:2016-03-25 12:13:20

标签: scala unit-testing equals specs2 nonetype

我使用specs2scala测试方法输出是否符合预期。测试如下:

call() must beEqualTo(expectedCall)

expectedCall是案例类的实例 - 与call()返回相同。当我运行测试时,我得到以下错误

[error]      'CustomScriptParsedOutput(0,Some(List(IntegrationRecordMsg(-500.12,2016-03-10T18:20:00.000+01:00,Some(some note, CZ),Some(CZK),Some(List(WITHDRAWAL))))),None,None): models.CustomScriptParsedOutput'
[error]
[error]       is not equal to
[error]
[error]      'CustomScriptParsedOutput(0,Some(List(IntegrationRecordMsg(-500.12,2016-03-10T18:20:00.000+01:00,Some(some note, CZ),Some(CZK),Some(List(WITHDRAWAL))))),None,None): models.CustomScriptParsedOutput' (CustomTest.scala:53)
[error] Actual:   ...None)
[error] Expected: ...None)

案例类的定义是:

case class CustomScriptParsedOutput(
    code: Int, 
    records: Option[List[RecordMsg]] = None, 
    amount: Option[AmountMsg] = None, 
    error: Option[ErrorMsg] = None
)

为什么None不等于None

1 个答案:

答案 0 :(得分:0)

我建议您测试不同行中的每个类属性,以便确定问题所在。我觉得None比较很难成为问题。除非2 None不是同一类型的选项?