Use Mockito in Spring Boot to Mock Test Object

preview_player
Показать описание
Use Mockito to mock out dependencies in our test objects. Use @MockBean, @Before, @SpringBootTest, and @RunWith annotations. See results of running the test with and without mocks.

Рекомендации по теме
Комментарии
Автор

Around 30:45, you mention that Mockito allows us to mock the downstream dependency of a class we don't want to test (in this case, SpecimenDAO). But the process of mocking it had a dependency on SpecimenDTO (lines 38-40 in SpecimenServiceTest), so aren't we still in the "integration" vs. unit test situation? You mentioned up front that you'd move through this one faster, but this one was extremely hard to follow compared to the other videos in this series; hopefully on re-watching it'll become a bit more clear.

almiller
Автор

At around 5:30, you're working with the PlantDTO and SpecimenDTO object types. Can you briefly explain the difference between these two object types in your application? They seem to be effectively the same thing, so I'm a little confused as to why both are used.

almiller