ScalaコードをテストするためにScalaTestを使用しています。私は現在、このようなコードで予想される例外をテストしています
import org.scalatest._
import org.scalatest.matchers.ShouldMatchers
class ImageComparisonTest extends FeatureSpec with ShouldMatchers{
feature("A test can throw an exception") {
scenario("when an exception is throw this is expected"){
evaluating { throw new Exception("message") } should produce [Exception]
}
}
}
しかし、例外に追加のチェックを追加したいと思います。たとえば、例外メッセージに特定の文字列が含まれていることを確認したいと思います。
これを行う「クリーンな」方法はありますか?または、try catch ブロックを使用する必要がありますか?