Test Driven Development (TDD) in Spring

preview_player
Показать описание
In this tutorial we take a TDD approach to testing our REST Controllers in Spring Boot. We will build out a small application and focus on UNIT testing the controller. In this test we are mainly focused on the inputs and outputs of the REST Controller.

🔗Resources & Links mentioned in this video:

👋🏻Connect with me:

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

Thank you, Dan, for this great content. I am looking forward to the next part, where you show us how the interplay between integration test and test container can be used. I love this channel. Thanks again.

dias
Автор

Omg Dan... When I see you writing code... It's a beautiful experience, you do it with a lot of quality and wisdom. excellent video about TDD!

alexdev__
Автор

Beatiful way to explain TDD, write the application using it. Thank you very much Dan.

gamires
Автор

Oh Yee, that is great.Although this is the right way First write a test then the code, but I don't do it. Either knowledge deficiencies or I am not so sure to do it.
Thank you so much. I have learned a new technique today and you helped me a lot with this TDD. Thank you God bless you🙏

Jamous
Автор

Thank you, I am learning a lot.
I see some gaps in your round TDD, like the list of (improvements, issues, and smell code) that list is part of the concept of driving code to the next level.
Another gap is the refactore in bove production code and test code because that can be aply when you repeat some parts of the test code, or for example, the moment you see the difficulty of isolating the test from de repository layer, when this issue pops up is a good time to try to refactor the code.

krlsdu
Автор

I have learned a lot with your daily videos. You make me want to quit my Javascript job and look for a Java one, idk why.

ElSrJuancho
Автор

LOL your timing on this video is AWESOME

JimShingler
Автор

Terrific Development with Dan, indeed

claveralvaro
Автор

The title is misleading: Dan shows some of the test-related features of Spring but that has nothing to do with actual TDD, is applies to just any automated test method. Dan mostly uses instead the "test last" method.

bodo_Te
Автор

what I like about hexagonal architecture is the ability to isolate your business logic and test it independently from the framework / DB.
it can be pure java without any dependencies, so we can test the most important part of the app quickly and iterate faster!

ilkou
Автор

In order to have maintainable tests, you should add additional layer which hides communication details of the REST client. Just introduce records to wrap the request and response and express the test semantics as plain as possible. Of course it adds time and complexity, but at the end it will help the team not to either create a mess in the tests or just abandon writing them. Also never use the objects (entity, dto) from the main code in your test, because if you change the JSON key name, effectively breaking the clients, tests will not catch that, because refactoring will rename everywhere.

Vanuatoo
Автор

This is a truly amazing video. Thanks Dan.

OneClickLabs
Автор

The TDD mantra:
Red -> Green -> Refactor!

joachimdietl
Автор

It was a great one Dan!! keep coming with it

Asingh
Автор

Hey Dan, Amazing content. Learnt so much. Just wanted to know the IntelliJ theme u r using, it seems very soothing for eyes.

scitechplusexplorer
Автор

Actually @Dan Vega, AutoConfigureMockMvc annotation is not necessary in order to use MockMvc. It's only when you want to do fine-grained configuration you'd need this.

ktunvlp
Автор

Hi Dan! Wonderful tutorial. However I have to point out few things you did wrong. It has to do mostly with using Post record with POST & PUT. You should have used DTO instead, because you should not pass the ID of the Post in the request body, when you create or update. And since you are validating the records, it would fail if you tried to exclude them. Or at least it should fail - they should be mandatory :)
Also you arbitrarily decided which attributes can be updated, which is not correct - in case of PUT, you update everything with the exception of an ID. If you do not provide new value, it is empty by default.
Other than that - I have no objections - nicely done and I can not wait to see your next tutorial on integration / unit tests.

P.S.: Just an idea - it would be great, if you could do the whole series on different types of tests - so for models / records, repositories, services, controllers, etc. Thanks!

jacup
Автор

I like your videos and I have been following you since 2018. Your content quality has been going up a lot lately!!

Regarding the topic, This is nice an all, but how do you approach TDD when you have a massive legacy app without tests and complex object(json) structures composed of quite a few objects, with a lot of db interactions (while many times you don’t have control over the db)..this is the truth most of the times in the java world. Don’t get me wrong, I love the video and thank you for the effort. I would like to see a more “realistic” approach, that’s all.cheers

petersteel
Автор

I liked the theme, what is it? You could leave your setup settings fixed, it's irrelevant, but people like me like that. And congratulations on this beautiful video.

EdsonLima-hpew
Автор

Thanks alot for this. But they TDD is always seriously demanded where I currently live

maneshipocrates
join shbcf.ru