0
specs2
とscala
を使用して、メソッド出力が期待通りにテストされています。試験は、次の通りである:Scala specs2 NoneがNoneと等しくない
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
に等しいではないでしょうか?
「None」が実際には等しくないのは確かですか?おそらく '-500.12'が問題だろうか? 'val res = call();を試してください。 res isEqualTo(res) ' –
これは' toString'出力を使って何が等しくないのかを表示しようとしていますが、それを見つけることはできません。おそらく 'RecordMsg'、' AmountMsg'、 'ErrorMsg'の型定義を共有しています。 –
各クラスの属性を個別にテストしようとしました。実際には、1つの属性、具体的には日付属性の障害のみです。 'toString'出力は私を混乱させました。 – kurochenko