789 B
789 B
On assertions
Answer the following questions:
-
The following assertion fails
assertTrue(3 * .4 == 1.2). Explain why and describe how this type of check should be done. -
What is the difference between
assertEqualsandassertSame? Show scenarios where they produce the same result and scenarios where they do not produce the same result. -
In classes we saw that
failis useful to mark code that should not be executed because an exception was expected before. Find other uses forfail. Explain the use case and add an example. -
In JUnit 4, an exception was expected using the
@Testannotation, while in JUnit 5 there is a special assertion methodassertThrows. In your opinion, what are the advantages of this new way of checking expected exceptions?