Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ScalaTest: how to properly assert over Try values?

Tags:

scalatest

At the moment if I need to test that a value v of Try[T] type is Success(t) I do like: v.isSuccess shouldBe true I wonder if there are probably some better ways. For example, for Option[T] we can assert like: t shouldBe defined Probably there is something like this for Try[T] but I am not aware and searching the web does not help.

like image 302
Alexander Arendar Avatar asked Mar 27 '17 18:03

Alexander Arendar


1 Answers

So far I came up with this solution: Based on this section of the ScalaTest docs we declare such symbol value: val successful = 'success and then assert like this:

CampaignRowsPage.reserveInventory shouldBe successful

Looks good to me.

like image 84
Alexander Arendar Avatar answered Oct 12 '22 04:10

Alexander Arendar