Skip to content

Comments

Дополнен pom зависимостями и плагинами, добавлены тесты по классу Burger#1252

Open
yanchilenkoaa-cmd wants to merge 7 commits intoyandex-praktikum:mainfrom
yanchilenkoaa-cmd:develop1
Open

Дополнен pom зависимостями и плагинами, добавлены тесты по классу Burger#1252
yanchilenkoaa-cmd wants to merge 7 commits intoyandex-praktikum:mainfrom
yanchilenkoaa-cmd:develop1

Conversation

@yanchilenkoaa-cmd
Copy link

Дополнен pom зависимостями и плагинами, добавлены тесты по классу Burger

@yanchilenkoaa-cmd
Copy link
Author

для проверки

@yanchilenkoaa-cmd
Copy link
Author

проверка

}

// Данные для параметризованных тестов по цене
@Parameterized.Parameters

Choose a reason for hiding this comment

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

⚠️Можно улучшить. В параметризованных тестах для аннотации Parameterized.Parameters лучше использовать аргумент name: @Parameterized.Parameters(name = "Тестовые данные: {0} {1}"), где {0}, {1} - индексы параметров. Это повысит информативность проверки

burger.addIngredient(ingredient2);

String receipt = burger.getReceipt();
assertTrue(receipt.contains("Ketchup"));

Choose a reason for hiding this comment

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

⛔️Нужно исправить. Для юнит-тестов придерживаемся подхода: один тест, значит одна проверка. Если очень хочется несколько проверок -- тогда используем softAssertions. Поправь, пожалуйста, во всем коде


@Test
public void testRemoveAndMoveIngredient() {
Ingredient ingredient1 = mock(Ingredient.class);

Choose a reason for hiding this comment

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

⛔️Нужно исправить. При нейминге не рекомендуется использовать числа (Field2), их еще называют magicNumbers. Очень тяжело поддерживать код с magicNumbers.

// Тест: установка булочек
@Test
public void testSetBuns() {
Bun mockBun = mock(Bun.class);

Choose a reason for hiding this comment

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

⛔️Нужно исправить. Тесты , где параметризация не нужна, необходимо вынести в отдельный класс

assertSame(mockBun, burger.bun);
}

// Тест: добавление ингредиентов

Choose a reason for hiding this comment

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

Image

⛔️Нужно исправить. Тесты упали

</executions>
</plugin>
</plugins>
</build>

Choose a reason for hiding this comment

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

⛔️Нужно исправить. Нужно приложить отчет в тестировании в пулл реквест

@yanchilenkoaa-cmd
Copy link
Author

Внесены исправления, класс с тестами разбит на 2 класса, приложен отчет

when(mockBun.getName()).thenReturn("Bun");
burger.setBuns(mockBun);

Ingredient ingredient1 = mock(Ingredient.class);

Choose a reason for hiding this comment

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

⛔️Нужно исправить. При нейминге не рекомендуется использовать числа (Field2), их еще называют magicNumbers. Очень тяжело поддерживать код с magicNumbers.

public void testAddIngredientIsPresent() {
Ingredient mockIngredient = mock(Ingredient.class);
burger.addIngredient(mockIngredient);
assertTrue(burger.ingredients.contains(mockIngredient));

Choose a reason for hiding this comment

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

⛔️Нужно исправить. Строку рецепта проверяем целиком, чтобы не пропустить ошибки форматирования

Choose a reason for hiding this comment

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

⛔️Нужно исправить. Нужно приложить папку jacoco

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.

2 participants