toString
明示的に使用しているため、このテストは問題ありません
"have one sentence by '...'" in {
val text1 = Text("some text...")
text1.sentences must have size(1)
text1.sentences(0).toString must_== "some text"
}
toSting
テストがない場合、次のようなメッセージで失敗します。
Expected :some text
Actual :some text
java.lang.Exception: 'some text: dictionary.Sentence' is not equal to 'some text: java.lang.String'
私はそれの意味を(一般的に)理解していますが、
toString
とにかく呼び出されるので、文字列から文字列をチェックするべきではありませんか?このテストを簡潔に書くための最良の方法は何ですか?
toString
直接使用せず に。