Skip to content
Open
Changes from 1 commit
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
23 changes: 18 additions & 5 deletions src/test/java/assertions/PersonTest.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package assertions;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import java.time.LocalDate;
import java.time.Period;

class PersonTest {

Expand All @@ -11,7 +13,10 @@ class PersonTest {
@Test
void getFullNameReturnsFirstnameSpaceLastname(){
// TODO implement
throw new IllegalArgumentException("you should implement code here");
// throw new IllegalArgumentException("you should implement code here");
Person pers1 = new Person("Tobias", "Meier", null);
Assertions.assertEquals("Tobias Meier",pers1.getFullName());

}

// TODO some more useful tests
Expand All @@ -20,19 +25,27 @@ void getFullNameReturnsFirstnameSpaceLastname(){
// --- getAge

@Test
void getAgeReturns10YearsIfBornIn2009() throws Exception {
void getAgeReturns10YearsIfBornIn2011() throws Exception {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stimmt der testmethodenname noch, wenn du den test in einem jahr wieder ausführst?

// TODO verbessern. Hinweis: Repeatable (wiederholbar) zu jeder Zeit.
Person p = new Person("", "", LocalDate.of(2009, 1, 1));
Person p = new Person("", "", LocalDate.now().minusYears(10));

throw new IllegalArgumentException("you should implement code here");
//throw new IllegalArgumentException("you should implement code here");
Period age = p.getAge();
Assertions.assertEquals(10,age.getYears());
Assertions.assertEquals(0, age.getMonths());
Assertions.assertEquals(0, age.getDays());
}

@Test
void getAgeReturns1DayIfYesterday() throws Exception {
Person p = new Person("", "", LocalDate.now().minusDays(1));

// TODO implement
throw new IllegalArgumentException("you should implement code here");
//throw new IllegalArgumentException("you should implement code here");
Period age = p.getAge();
Assertions.assertEquals(1,age.getDays());
Assertions.assertEquals(0, age.getMonths());
Assertions.assertEquals(0, age.getYears());
}

// TODO some more useful tests
Expand Down