2025 init

This commit is contained in:
Romain Lefeuvre
2025-11-18 14:43:08 +01:00
commit 7155dd77be
39 changed files with 1134 additions and 0 deletions

13
exercises/assertions.md Normal file
View File

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