diff --git a/src/test/java/guru/springframework/sfgpetclinic/controllers/IndexControllerTest.java b/src/test/java/guru/springframework/sfgpetclinic/controllers/IndexControllerTest.java new file mode 100644 index 00000000..6ff76aef --- /dev/null +++ b/src/test/java/guru/springframework/sfgpetclinic/controllers/IndexControllerTest.java @@ -0,0 +1,30 @@ +package guru.springframework.sfgpetclinic.controllers; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class IndexControllerTest { + + IndexController controller; + + @BeforeEach + void setUp() { + controller = new IndexController(); + } + + @Test + void index() { + assertEquals("index", controller.index()); + assertEquals("index", controller.index(), "Wrong value returned"); + assertEquals("index", controller.index(), () -> "Another expensive message" + + " Make only if necessary"); + } + + @Test + void oupsHandler() { + assertTrue("notimplemented".equals(controller.oupsHandler()), () -> "This is some expensive message" + + "to build for the test"); + } +} \ No newline at end of file diff --git a/src/test/java/guru/springframework/sfgpetclinic/model/PersonTest.java b/src/test/java/guru/springframework/sfgpetclinic/model/PersonTest.java new file mode 100644 index 00000000..7a8ddd4f --- /dev/null +++ b/src/test/java/guru/springframework/sfgpetclinic/model/PersonTest.java @@ -0,0 +1,30 @@ +package guru.springframework.sfgpetclinic.model; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.*; + +class PersonTest { + + @Test + void groupedAssertions() { + //given + Person person = new Person(1L, "Joe", "Buck"); + + //then + assertAll("Test Props Set", + () -> assertEquals(person.getFirstName(), "Joe"), + () -> assertEquals(person.getLastName(), "Buck")); + } + + @Test + void groupedAssertionMsgs() { + //given + Person person = new Person(1L, "Joe", "Buck"); + + //then + assertAll("Test Props Set", + () -> assertEquals(person.getFirstName(), "Joe", "First Name failed"), + () -> assertEquals(person.getLastName(), "Buck", "Last Name Failed")); + } +} \ No newline at end of file