From 5fd954496a586064272bb7a7c18aab89cfc5bbb0 Mon Sep 17 00:00:00 2001 From: Adrian Stoica <stoica@ntnu.no> Date: Wed, 22 Sep 2021 15:55:39 +0200 Subject: [PATCH] updates slides for lecture 7 --- lectures/revealjs/07-lecture.adoc | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/lectures/revealjs/07-lecture.adoc b/lectures/revealjs/07-lecture.adoc index 8572587..18a7804 100644 --- a/lectures/revealjs/07-lecture.adoc +++ b/lectures/revealjs/07-lecture.adoc @@ -217,11 +217,29 @@ public class FoobarTest { |=== +== Expecting exceptions (1) + +``` java +@Test +void testAssertingExpectedException() { + Assertions.assertThrows(<ExpectedException.class>, () -> { + <code expected to throw exception>; + }); +} +``` + +== Expecting exceptions (2) + +- if the code throws +** the exception class that is expected the the test will PASS +** a descendent class exception that is expected the the test will PASS +** a different exception type the test will FAIL +** throws no exception the test will FAIL + [background-color = "#124990"] [color = "#fff6d5"] == Testing in todo-list example - include::{includedir}footer.adoc[] \ No newline at end of file -- GitLab