Creating Unit Tests with Spring Boot

preview_player
Показать описание

This video is part of the Spring Boot Fundamentals series. In this video, we build upon the Greeting web services project, constructing an extensible unit test class hierarchy for the application components.

If you are looking for web controller unit tests, see the next video in this series where we extend the unit testing framework to test Spring web controller components using mock objects.
Рекомендации по теме
Комментарии
Автор

Your voice is so calm and clear. Awesome tutorial!

CrashTestDummy
Автор

= Application.class) is deprecated in version 1.4.0. Instead you can use @SpringBootTest(classes = Application.class).

Also, the Junit will have one failure in "testCreateWithId" because of unmentioned changes in the video where we were returning null before, and now we need to throw an "EntityExistsException" so the test will pass. If you look at GreetingServiceBean.java in GitHub, there is a change there which will make the code pass the junit, but no mention of the change in the video...

Not a big deal if you are always pulling the latest code down, but I'm building on the fly to help me figure things out myself with the video as a guide how to do it. Helps me learn better than just blinding taking all the code and gives me more practice debugging.

PaulsTrains
Автор

I would suggest to use @Test(expected = ExceptionClassType.class) annotation for testing exceptional situations (it will make test code smaller and readable)

ixlzlkb
Автор

How to include the test classes(src/test) in the main jar, so that it can it can be executed as java command, what changes has to carried out in the pom.

premierde
Автор

1:45 The abstract class AbstractTest will be the base class for all the project unit tests

ruixue
Автор

Delete test case failed when I tried, It passed when I commented the @Cacheable annotation in front of the findOne method in GreetingServiceBean class.

enderculha
Автор

This is deprecated, please, drop the video or add link to new documentation. Now use and @RunWith(SpringRunner.class)

whk
Автор

THIS TUTORIAL IS DEPRECATED, PLS UPDATE IT OR DELETE IT, IT'S CONFUSING

luispa