-
Notifications
You must be signed in to change notification settings - Fork 2k
Создание pom.xml , и покрытие тестами класса Burger #1135
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
| }, | ||
| { | ||
| new Bun("VIP", 125.5f), | ||
| new Ingredient[]{ |
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.
⛔️Нужно исправить. Для всех зависимостей нужно использовать моки
| @Test | ||
| public void addIngredientShouldAddIngredientToList() { | ||
| burger.addIngredient(mockIngredient1); | ||
| assertFalse("Список ингредиентов не должен быть пустым", burger.ingredients.isEmpty()); |
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. Поправь, пожалуйста, во всем коде
| @Mock | ||
| private Bun mockBun; | ||
| @Mock | ||
| private Ingredient mockIngredient1; |
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.
| String actualReceipt = burger.getReceipt(); | ||
| assertEquals("Сгенерированный чек не соответствует ожидаемому", expectedReceipt, actualReceipt); | ||
| } | ||
| } |
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.
⛔️Нужно исправить. Приложи, пожалуйста, отчет о тестировании
|
|
||
| assertEquals("Сгенерированный чек не соответствует ожидаемому", expectedReceipt, actualReceipt); | ||
| } | ||
| } |
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.
⛔️Нужно исправить. нет отчета о тестировании
# Conflicts: # src/test/java/praktikum/BurgerPriceParameterizedTest.java # src/test/java/praktikum/BurgerTest.java

Подключены и настроены зависимости для тестирования в pom.xml: JUnit 4, Mockito и плагин JaCoCo.
Написан полный набор юнит-тестов для класса Burger, обеспечивающий 100% покрытие кода.
В тестах применены моки и стабы (с помощью Mockito) для изоляции тестируемого класса от зависимостей.
Реализованы параметризованные тесты для проверки логики расчёта цены бургера с разными наборами данных.
Отлажен процесс сборки проекта и генерации отчёта о покрытии с помощью команды Maven mvn clean verify.