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

V2.0 Changes on PersonTest, ValidatorTest, UserControllerTest #13

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

rrecon
Copy link

@rrecon rrecon commented Nov 2, 2019

  • new Tests on PersonTest
  • new Tests on validatortest
  • not all tests finished in ValidatorTest
  • Didn't get a solution for UserControllerTest

Starting TestUnit
More changes
PersonTest changed
+ added new tests to PersonTest
+ Tried UserControllerTest but didn't find a answer
+ Added new tests to ValidatorTest
- In ValidatorTest are not all tests finished

String fullName = p.getFullName();

Assertions.assertFalse(Boolean.parseBoolean(fullName), "Hannes Meier");
Copy link
Contributor

Choose a reason for hiding this comment

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

Wieso machst du parseBoolean("1Hannes 2Meier") ?
Das zweite Argument "Hannes Meier" ist ja nur die Message welche angezeigt wird, wenn die Assertion fehlschlägt.

}

@Test
void getAge_ReturnsTrueWhenDifferentAge(){
Copy link
Contributor

Choose a reason for hiding this comment

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

getAge retourniert eine Zahl, die wird nie True sein.

void Person_TrueIf2ObjectsAreNotEqual(){
Person p = new Person("Hannes", "Meier", LocalDate.of(1940, 6, 30));
Person c = new Person("Petra", "Meier", LocalDate.of(1950, 3, 12));
Assertions.assertNotSame(p, c);
Copy link
Contributor

Choose a reason for hiding this comment

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

assertNotSame prüft nicht auf Equality, sondern Identity (im Testnamen redest du aber von Equality).

Copy link

@vinkja vinkja left a comment

Choose a reason for hiding this comment

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

Krass viele tests hast du hier. Aber he! Wir müssen imfall nur die //TODO einträge lösen... streber 😂.

throw new IllegalArgumentException("you should implement code here");
db.addUser(user1);

Assertions.assertTrue(UserValidator.isValidUsername(user2.getUsername()) && !UserValidator.doesUsernameExist(user2.getUsername()));
Copy link
Contributor

Choose a reason for hiding this comment

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

Die inner static class heisst "doesUsernameExist", es ist also nicht nötig isValidUsername hier überhaupt aufzurufen, da du ja doesUsernameExist testen willst. Generell kann man sagen, dass es nicht empfohlen wird logische Verknüpfungen zu testen (ausser natürlich im Test geht es genau um darum ;)).

void returnsFalseIfUsernameNotInDBYet(){
throw new IllegalArgumentException("you should implement code here");
}
void returnsTrueIfUsernameNotInDBYet(){
Copy link
Contributor

Choose a reason for hiding this comment

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

Unten prüfst du auf "assertTrue(!UserValidator.doesUsernameExist())", das ist ja genau das Gegenteil von "returnsTrue".


Assertions.assertTrue(UserValidator.isValidUsername(user2.getUsername()) && !UserValidator.doesUsernameExist(user2.getUsername()));
//False if in DB
Assertions.assertFalse(!UserValidator.doesUsernameExist(user1.getUsername()));
Copy link
Contributor

Choose a reason for hiding this comment

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

wie im obigen Test reicht dieses zweite assert aus, da es genau das ist, was du im Testnamen angibst zu testen.

UserController test2 = new UserController();

Message message1 = new Message();
Method privateMessage = Message.class.getDeclaredMethod("Message", String.class);
Copy link
Contributor

Choose a reason for hiding this comment

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

Von welcher PowerPoint Folie oder Übung hast du denn das her :)?
I.d.R. kann man davon ausgehen, dass die vermittelten Kursinhalte ausreichen um die Übungen zu lösen (Hinweis: Im Testnamen steht gross MOCKITO :)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants