factor10 / intent

Test framework for Dotty
https://factor10.github.io/intent/
Apache License 2.0
13 stars 4 forks source link

Syntax for toThrow? #28

Closed provegard closed 4 years ago

provegard commented 4 years ago

For example:

expect(<...>).toThrow[IllegalArgumentException]()

With message (regex?)

expect(<...>).toThrow[IllegalArgumentException]("it failed")

Or with pattern matching:

expect(<...>).toThrow:
  case ex: IllegalArgumentException => expect(ex.getMessage).toMatch(...)

But there are two expects there... We could do it like whenComplete:

expectFailure(<...>):
  ex => ... // could do pattern matching here also

Or something like intercept in ScalaTest.

@eliasson thoughts?

eliasson commented 4 years ago

For example: With message (regex?)

expect(<...>).toThrow[IllegalArgumentException]("it failed")

This one. I often find that you want to make some assert on type and message (type alone is too weak IMO)

And if you need pattern matching in an assert you really should split the test into multiple tests.

provegard commented 4 years ago

Fixed in #37