I have read that assume
will not run the test if assumption failed,
but I am not sure regarding the logic of when to place assert
vs assume
.
For example: any resource loading check should be done with assume
?
When should I use assume
over assert
?
(Note: i am looking for correct design of when to use one over the other)
As you already know, you use assert
to fail a test if something goes wrong.
You use assume
if you have circumstances under which a test should not run. "Not run" means that it cannot fail, because, well, it did not run.
So, in a hypothetical scenario where:
you would write a test which:
Technically, both assert
and assume
throw exceptions. The difference is that:
assert
will cause the test to fail, whileassume
will cause the test to be skipped.