jeudi 30 avril 2020

Scalatest: Combine Assertions

I've just started using WordSpec and I've come across a problem I can't get around.

I'd like to assert on two separate values in one unit test. Suppose I have val result1 and val result2, I need the first to take on a particular value AND the second to take on another particular value.

This would be really easy if it was possible to concatenate/reduce/fold on assertions but I don't think I can. Perhaps something like this:

result1 should be (1) ++ result2 should be (2)

The result would be a new assertion which is only true if both assertions are true.

If I write them as below, it will only take the last value.

result1 should be (1)
result2 should be (2)

Does anyone know a way around this?

Aucun commentaire:

Enregistrer un commentaire