-
Notifications
You must be signed in to change notification settings - Fork 2k
Добавил тесты на бургер, покрытие JoCoCo 100% #1146
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
base: main
Are you sure you want to change the base?
Conversation
| private Bun bun; | ||
|
|
||
| @Mock | ||
| private Ingredient ingredient1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛔️Нужно исправить. При нейминге не рекомендуется использовать числа (Field2), их еще называют magicNumbers. Очень тяжело поддерживать код с magicNumbers.
| burger = new Burger(); | ||
| } | ||
|
|
||
| @Parameterized.Parameters |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| public void testSetBuns() { | ||
| when(bun.getName()).thenReturn(bunName); | ||
| when(bun.getPrice()).thenReturn(bunPrice); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛔️Нужно исправить. Тесты, где не нужна параметризация, нужно вынести в отдельный класс. Мы не должны их запускать несколько раз
|
|
||
| burger.addIngredient(ingredient1); | ||
|
|
||
| assertEquals(1, burger.ingredients.size()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
⛔️Нужно исправить. Для юнит-тестов придерживаемся подхода: один тест, значит одна проверка. Если очень хочется несколько проверок -- тогда используем softAssertions. Поправь, пожалуйста, во всем коде
…tests into BurgerTest and BurgerSimpleTest, update .gitignore
Подключил библиотеки Jococo, Junit4, Mockito. Провел тестирование класса Burger, по результатам отчета Jococo составило 100%