Mock, When and ThenReturn with Mockito - JUnit Tutorial

preview_player
Показать описание
Learn about what a mocking framework is used for with unit testing, when we it would want to use it, and how we can use the Mockito framework within our tests.
This tutorial involves testing a class method in isolation despite its dependency upon a database call. We will understand why mocking is useful and how we can approach it in 3 steps.

Comment, like and subscribe for more content on Java and software engineering.

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

Thank god you popped out as I was looking for a mockito tutorial. Clear explanation, good speed, HD quality, and understandable examples. You're doing great, keep it up!👍 🔥

mrpunch__
Автор

Thanks a lot, the most comprehensive video on youtube, watched like 3 other before this one... everywhere lots of unneeded information, unnecessary repetitions of useless information. Your video is exactly on the topic, nothing more, nothing else. Please make more videos of that kind :)

dariamusinova
Автор

This channel is underrated. Subscribed!

smithcodes
Автор

Hey man a little late here, but I hope you're doing well. I loved the series and helped me adapt to my new work super fast!

ekrarefaz
Автор

Man I was so confused when I saw when and thenReturn in my org's code, thank you so much for this video. You saved me.

ShubhamSharma-sfwk
Автор

very nice explanation and very pleasant voice. keep going!

TomaAndreiMusic
Автор

simple and best explanation of the concept..It would be awesome to see more detailed videos with other options of Mockito.

cashew
Автор

This is the one. This is the video I was seeking. Thanks!!

aldolunabueno
Автор

Thanks, nobody explain what when and thenReturn do, and is very simple, is, when you executed this Injected Class, simulate (thenReturn) with the data is in the setup or init or before method annotated.

gonzalooviedo
Автор

Clear and concise. Wonderful video. Thanks for this

chizebamaulu
Автор

Clear and straight to the point, nice job!

shikuanchung
Автор

Thanks for the video! The GitHub Repo link was much useful.

srujanan
Автор

YOUR ARE MY SAVIOUR BROTHER LOVE THIS PLAYLIST

jagadeeshp
Автор

what a great video! thank you so much! it was better than googling around for 1 hr+!

efecu
Автор

Lovely men, so simple exaple to understand, i was Lost in complex examples. thank you 😊

bilaldmx
Автор

Very helpful videos. Thank you again. One thing I faced was mock object could not be created.

I was getting:
Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String, byte[], int, int) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module

Thank I had to add jvm argument: --illegal-access=warn --add-opens

zahirulislam
Автор

Like I am test testing the business service layer of my spring rest web project with Spring data jpa . So should I create mock stubs for repository interfaces for testing the Business layer which is interacting with DAO layer?

sahilvishwakarma
Автор

at 5:18, is the setup function be the same meaning as hotelDao annotated by @Mock?

hbycodingacademic
Автор

Will it execute method which is mocked?

Vinayakgohel
Автор

can you also make a video for REST API using Java ?

HenryLeu