Skip to content

Sprint_6#5

Open
adelikade wants to merge 4 commits intomainfrom
develop
Open

Sprint_6#5
adelikade wants to merge 4 commits intomainfrom
develop

Conversation

@adelikade
Copy link
Owner

No description provided.

Copy link

@pomegranate282922 pomegranate282922 left a comment

Choose a reason for hiding this comment

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

Работа очень хорошая! Изоляция, моки и стабы сделаны отлично.
Но с темой параметризации нужно ещё поработать. Нужно убрать ее оттуда, где она не нужна, и наоборот найти достойное ей применение.

<maven.compiler.target>11</maven.compiler.target>
</properties>

<dependencies>

Choose a reason for hiding this comment

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

Файлы .idea коммитить не нужно . Нужно добавить их в gitignore. Нужно исправить

hasMane = false;
} else {
throw new Exception("Используйте допустимые значения пола животного - самей или самка");
throw new Exception("Используйте допустимые значения пола животного - самец или самка");

Choose a reason for hiding this comment

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

Отлично! Изоляция выполнена верно.

List<String> expectedFood = List.of("Животные", "Птицы", "Рыба");
Mockito.when(feline.eatMeat()).thenReturn(expectedFood);
assertEquals("Кошка должна есть мясо", expectedFood, cat.getFood());
Mockito.verify(feline, Mockito.times(1)).eatMeat();

Choose a reason for hiding this comment

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

Отлично! Уместно применен verify.

Feline feline = new Feline();
List<String> actualFood = feline.eatMeat();
boolean actualResult = felineFood.equals(actualFood);
assertEquals("Кошачьи едят мясо", expectedResult, actualResult);

Choose a reason for hiding this comment

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

Это слишком многословно, хотя по сути достаточно assertEquals между животные птицы рыба и actualResult.

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.

Нужно исправить

boolean actualResult = felineFood.equals(actualFood);
assertEquals("Кошачьи едят мясо", expectedResult, actualResult);
System.out.println("Результат выполнения теста:");
System.out.println(actualResult == expectedResult);

Choose a reason for hiding this comment

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

Это нужно убрать. Если тест красный, ошибка от ассерта и так выведет информацию. Если зелёный - мы и так видим, что тест прошёл.

assertEquals("Должно быть семейство кошачьих", expectedResult, actualResult);
System.out.println("Результат выполнения теста:");
System.out.println(actualResult == expectedResult);
}

Choose a reason for hiding this comment

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

Аналогичное замечание. Нужно исправить

assertEquals("У кошачьих 1 котенок", expectedResult, actualResult);
System.out.println("Результат выполнения теста:");
System.out.println(actualResult == expectedResult);
}

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.

Нужно ещё раз разобраться, для чего используется параметризация. Чтобы протестировать метод, передав в него различные параметры.

Exception exception = Assert.assertThrows(Exception.class, () -> {
new Lion("Man", feline);
});
Assert.assertEquals("Используйте допустимые значения пола животного - самец или самка", exception.getMessage());

Choose a reason for hiding this comment

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

Отлично протестировано исключение!

Copy link

@pomegranate282922 pomegranate282922 left a comment

Choose a reason for hiding this comment

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

Да, теперь параметризация применена Верно.
Ещё можно использовать ее для теста метода doesHaveMane.
Осталось одно важное замечание, которое необходимо исправить.

@Parameterized.Parameters(name = "{index}: {0}-{1}")
public static Iterable<Object[]> data() {
return Arrays.asList(new Object[][]{
{1, 1},

Choose a reason for hiding this comment

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

Так как значение одно и то же, можно использовать один параметр.

});
Assert.assertEquals("Используйте допустимые значения пола животного - самец или самка", exception.getMessage());
}
} No newline at end of file

Choose a reason for hiding this comment

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

Каждый тест в этом классе повторится дважды, так как они находятся в параметризованном классе. Это нехорошо, нужно разнести по разным классам тесты, нуждающиеся в параметризации, и остальные.

…чень большая просьба, если нет критичных замечаний, принять работу:к сожалению, иначе мне недоступен следующий финальный проект, дедлайн по которому на этой неделе.
Copy link

@pomegranate282922 pomegranate282922 left a comment

Choose a reason for hiding this comment

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

Ок, зачёт!

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