You changed my life of spring developper and i'm ready to buy on your plateforme a complete course of how to deploy spring boot project on aws (AWS Amplify, AWS S3, AWS RDS, AWS EC2). It will be a pleasure to follow such course. Thanks for everything
*Table of Contents* (By the way, a "mock" is an empty version of an object, and a "stub" is a mock with some functionality added back in.) 00:00 Testing is important, here's why 06:05 What is Spring Test? (tl;dw it's a testing library for Java). 8:49 How the example program is organized (tl;dw StudentMapper has a Student object with student info, and has a StudentResponseDto object (Dto stands for Data transfer object). StudentService has a StudentRepository object and a StudentMapper object.) 10:59 Making a test class for StudentMapper 14:58 Test Class exists, first (Hello World) test function ``` @Test public void testMethod1(){ System.out.println(“My first test method”); } ``` 16:50 The SetUp method, @BeforeEach 19:01 The TearDown method, @AfterEach 20:42 @BeforeAll (BeforeClass) method 22:30 @AfterAll (AfterClass) method 23:55 First actual test, and what the StudentMapper functions do 29:57 First test is done and runs 30:06 Causing the first test to fail 32:07 Practice Exercise - implement test for toStudentResponseDto method 32:50 Practice Exercise answer 34:44 Given, When, Then, test structure 35:39 Third test: studentDto to student if null. 38:15 Fixing the source code to handle null. Adjusting test to expect exception, and getting the exception message (assertThrows(exceptionType, () -> { code });) 42:31 Explanation of StudentService and database, test isolation with mocking (Mockito) 45:01 Creating new test class for StudentService 46:30 First and second @Mock 47:33 @InjectMocks 48:22 Opening/starting the mocks (MockitoAnnotations.openMocks(this);) 49:21 First test method for StudentService, saving a student 52:48 Why the result is null/failing. Mocking functions for test isolation’s sake. when().thenReturn() 57:31 Test with mocks (and stubs) is ready and runs 59:06 Making sure the methods were only called once, using Mockito.verify() 1:02:20 Practice Exercise - test findAllStudent() method, using mocks (and stubs) as needed 1:02:53 Practice Exercise answer (including using mockito any() method) 1:06:33 Practice Exercise - test findStudentById() method 1:06:52 Practice Exercise answer (including Optional.of()) 1:10:07 Bouali Ali is proud of you 1:10:13 Practice Exercise - test findStudentsByName() 1:10:45 Practice Exercise answer
please make more videos on unit testing and mockito which used more complex code like service class depends on multiple different service class and use spring security for authorization and authentication and encryption decryption for request and response object. Your video is really helpful and thanks sir for sharing your great knowledge with us.
Great Video!!! Could you provide us with the link to the repository? How to test controller classes ? How do you test the database connection and whether data is read and saved correctly?
Do you have a complete course on testing, where we can get the initial code to learn along with you? I enrolled into your platform, the content is awesome, thanks for the effort.
Could you do a video about how to be in testing with jwt-security ? how to add jwts or fake jwts when testing and how to test login or auth methods, endpoints?
I think that the repository level must be tested first of all. It doesn't need to test basic CRUD operations of a repository. But we have a lot of fun besides. For insance, test the fact that repository realy gives an id for a new entity. Does the audit feature (createdAt, modifiedAt) realy work? Does it throw correct exceptions? Does your SQL query correspond to your expectations? How to mock DB (embedded, docker) ...
You changed my life of spring developper and i'm ready to buy on your plateforme a complete course of how to deploy spring boot project on aws (AWS Amplify, AWS S3, AWS RDS, AWS EC2). It will be a pleasure to follow such course. Thanks for everything
now, all my content is and will be for free. No one should pay to learn
You are welcome to contribute if you want to
Thank you for the simple and straight forward explanations.
*Table of Contents*
(By the way, a "mock" is an empty version of an object, and a "stub" is a mock with some functionality added back in.)
00:00 Testing is important, here's why
06:05 What is Spring Test?
(tl;dw it's a testing library for Java).
8:49 How the example program is organized
(tl;dw StudentMapper has a Student object with student info, and has a StudentResponseDto object (Dto stands for Data transfer object). StudentService has a StudentRepository object and a StudentMapper object.)
10:59 Making a test class for StudentMapper
14:58 Test Class exists, first (Hello World) test function
```
@Test
public void testMethod1(){
System.out.println(“My first test method”);
}
```
16:50 The SetUp method, @BeforeEach
19:01 The TearDown method, @AfterEach
20:42 @BeforeAll (BeforeClass) method
22:30 @AfterAll (AfterClass) method
23:55 First actual test, and what the StudentMapper functions do
29:57 First test is done and runs
30:06 Causing the first test to fail
32:07 Practice Exercise - implement test for toStudentResponseDto method
32:50 Practice Exercise answer
34:44 Given, When, Then, test structure
35:39 Third test: studentDto to student if null.
38:15 Fixing the source code to handle null. Adjusting test to expect exception, and getting the exception message (assertThrows(exceptionType, () -> { code });)
42:31 Explanation of StudentService and database, test isolation with mocking (Mockito)
45:01 Creating new test class for StudentService
46:30 First and second @Mock
47:33 @InjectMocks
48:22 Opening/starting the mocks (MockitoAnnotations.openMocks(this);)
49:21 First test method for StudentService, saving a student
52:48 Why the result is null/failing. Mocking functions for test isolation’s sake. when().thenReturn()
57:31 Test with mocks (and stubs) is ready and runs
59:06 Making sure the methods were only called once, using Mockito.verify()
1:02:20 Practice Exercise - test findAllStudent() method, using mocks (and stubs) as needed
1:02:53 Practice Exercise answer (including using mockito any() method)
1:06:33 Practice Exercise - test findStudentById() method
1:06:52 Practice Exercise answer (including Optional.of())
1:10:07 Bouali Ali is proud of you
1:10:13 Practice Exercise - test findStudentsByName()
1:10:45 Practice Exercise answer
Perfect Upload. I was just learning about unit & integration testing & you've uploaded at the right time. Thanks a lot !
Glad it was helpful!
Can you make a video about using Redis in Spring Boot and PostgreSQL?
soon
@@BoualiAli please make a video for integration testing with the redis and postgresql in springboot 3.
can you do more videos about testing ? perhaps testing the controller layer ? i loved the lecture, you helped me a lot. 😊
Yes, soon
Interessting and well understanding, big thanks
Perfectly explained, thank you Mr.Perfecto
بارك الله فيك و يرحم والديك ، جات الوقت المناسب
baraka allahou fik
Always providing high quality Content , THANK YOU !!
Glad you think so!
Sir codesource please is not in the description
Do we have the video of development / Implementation of that Student project ?
Thank you for this video. Please continue topic of testing.
sure
please make more videos on unit testing and mockito which used more complex code like service class depends on multiple different service class and use spring security for authorization and authentication and encryption decryption for request and response object. Your video is really helpful and thanks sir for sharing your great knowledge with us.
noted
You are a fantastic teacher. Thanks a lot. Can you please cover integration testing of REST services ?
Yes, soon
Hi Alibou, Your content is very good, much appreciated. It would've been even great if you've covered code coverage as well.
Thanks
Great Video!!! Could you provide us with the link to the repository? How to test controller classes ? How do you test the database connection and whether data is read and saved correctly?
Thanks, it is excellent illustration
I'm glad you like it
Thank you man, this video is really helpful
Glad you liked it!
Literally amazing tutorial, the only thing missing was testing the controller.
Thanks. Great explanation as usual
My pleasure!
Should you write test first before implementation or the other way round?
Very nice boulai Ali thank you☺️☺️☺️🎁🙏🏾🙏🏾 for the video happy the new year
Glad you liked it!
Great content, keep going !!
Glad you liked it!
Do you have a complete course on testing, where we can get the initial code to learn along with you? I enrolled into your platform, the content is awesome, thanks for the effort.
Thank you very much. Really appreciate your for your effert ❤❤❤❤
my pleasure
Hi Bouali , do you have any videos on integration testing? it could be a payed version too, really interested if you do. thanks!
you're amazing thanks !
Awesome dude ❤🙏🙏🙏
Glad you think so!
I had the same query asked below. Want to know the spring boot version used here.
spring 3
Can you please upload the link for the code used in this tutorial. I couldn't find it in the description.
where is the repo for the demo, in order to follow it?
can you tell me which repo, you used for the testing, can you provide the link?
I dont have a repo for it
Could you do a video about how to be in testing with jwt-security ? how to add jwts or fake jwts when testing and how to test login or auth methods, endpoints?
good idea
Waiting for it
This is a great video explaining the basic concept for ut. please can you provide the code source for all app not including for test part
there is no app for that. just showcase services
After One month Sir ALi Bouali come Back 🥰
How to see the class diagram that you showed?
If you are using Intellij, go to the module / directory, right click and choose diagrams, Its one of the last options. Thank me later.
best as always
Thank you
You're welcome
I think that the repository level must be tested first of all. It doesn't need to test basic CRUD operations of a repository. But we have a lot of fun besides. For insance, test the fact that repository realy gives an id for a new entity. Does the audit feature (createdAt, modifiedAt) realy work? Does it throw correct exceptions? Does your SQL query correspond to your expectations? How to mock DB (embedded, docker) ...
This is the integration tests level.
I will cover it soon
where can I find the code for this video?
in the description
@@BoualiAli cant find it in description
how can i find the source code of this project ?
saha aloulou
you're the best
Can you make a video about Integration testing?
soon
Can you make videos on DevOps
which part of it?
hi Ali, can i get the source code link?
Thanks a lot. Can you please share source code?
In the description
githup ?? this video resoruce