Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Junit5 tests #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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");
}
}
Original file line number Diff line number Diff line change
@@ -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"));
}
}