title
Mockito JUnit Example

description
In this video will will see JUnit Mockito example And Mockito framework Spring Full Course : https://courses.telusko.com/learn/Spring5 Spring Full Course (UDEMY) : https://www.udemy.com/spring-5-with-spring-boot-2/?couponCode=TELUSKOJULY Angular Full Course : https://courses.telusko.com/learn/Angular We will learn : Creating Stub Using Mockito Framework Adding Mockito dependency Using mock service Using when...thenReturn of Mockito Using @Mock and @Rule annotations Trainer: Navin Reddy Editing Monitors : https://amzn.to/2RfKWgL https://amzn.to/2Q665JW https://amzn.to/2OUP21a. Check out our website: http://www.telusko.com Follow Telusko on Twitter: https://twitter.com/navinreddy20 Follow on Facebook: Telusko : https://www.facebook.com/teluskolearn... Navin Reddy : https://www.facebook.com/navintelusko Follow Navin Reddy on Instagram: https://www.instagram.com/navinreddy20 Subscribe to our other channel: Navin Reddy : https://www.youtube.com/channel/UCxmk... Telusko Hindi : https://www.youtube.com/channel/UCitz... Donation: PayPal Id : navinreddy20 Patreon : navinreddy20 http://www.telusko.com/contactus Java Tutorial : https://goo.gl/p10QfB REST Tutorial : https://goo.gl/3mosnz Kotlin Tutorial : https://goo.gl/JedEzX Scala Tutorials for Java Developers : https://goo.gl/8H1aE5 C Tutorial Playlist : https://goo.gl/8v92pu Android Tutorial : https://goo.gl/MzlIUJ XML Tutorial : https://goo.gl/Eo79do Design Patterns in Java : https://goo.gl/Kd2MWE Socket Programming in Java : https://goo.gl/jlMEbg Spring MVC Tutorial : https://goo.gl/9ubbG2 OpenShift Tutorial for Beginners : https://goo.gl/s58BQH Spring Framework with Maven : https://goo.gl/MaEluO Sql Tutorial for Beginners : https://goo.gl/x3PrTg String Handling in Java : https://goo.gl/zUdPwa Array in Java : https://goo.gl/uXTaUy Java Servlet : https://goo.gl/R5nHp8 Exception Handling in Java : https://goo.gl/N4NbAW

detail
{'title': 'Mockito JUnit Example', 'heatmap': [{'end': 1045.708, 'start': 1029.733, 'weight': 1}], 'summary': 'Demonstrates using mockito and junit for testing a calculator service, covering addition and multiplication operations and emphasizing the use of mock objects and managing dependencies. it also explains the process of using mockito for test automation and unit testing, including specifying behavior for method calls and creating mock objects.', 'chapters': [{'end': 202.401, 'segs': [{'end': 118.909, 'src': 'embed', 'start': 55.978, 'weight': 0, 'content': [{'end': 61.682, 'text': 'Of course you need a cloud service, right? Now this is not just for cloud service, maybe for database operation.', 'start': 55.978, 'duration': 5.704}, {'end': 66.826, 'text': "So let's say we have a Calculator service who will provide the service for me.", 'start': 62.422, 'duration': 4.404}, {'end': 69.732, 'text': 'and the way i was testing it.', 'start': 68.13, 'duration': 1.602}, {'end': 79.502, 'text': 'i was using j unit for testing and in the before i have done with the setup of creating a greater object and in we have a method which is test add,', 'start': 69.732, 'duration': 9.77}, {'end': 80.943, 'text': 'which will test it right.', 'start': 79.502, 'duration': 1.441}, {'end': 83.906, 'text': 'we have used assert equals.', 'start': 80.943, 'duration': 2.963}, {'end': 90.626, 'text': 'now what i want to do here is, if I look at this calculator service, this is a simple interface.', 'start': 83.906, 'duration': 6.72}, {'end': 93.388, 'text': 'right now what I will do is I want to.', 'start': 90.626, 'duration': 2.762}, {'end': 101.854, 'text': "so instead of going for add, let's go for another method which is called perform, just to get that feeling of having some cloud service.", 'start': 93.388, 'duration': 8.466}, {'end': 107.298, 'text': "so let's say, whenever I create object of calculator, and if I say perform by passing two values, let's say two and three,", 'start': 101.854, 'duration': 5.444}, {'end': 116.247, 'text': "the output i'm expecting is example if i pass 2 and 3, the output i'm expecting is the addition of those these two numbers, which is 5,", 'start': 108.138, 'duration': 8.109}, {'end': 118.909, 'text': 'into the first number.', 'start': 116.247, 'duration': 2.662}], 'summary': 'Transitioning from testing add method to perform method for cloud service feeling, expecting 5 as output.', 'duration': 62.931, 'max_score': 55.978, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HsQ9OwKA79s/pics/HsQ9OwKA79s55978.jpg'}], 'start': 0.609, 'title': 'Testing calculator service', 'summary': 'Covers implementing mockito for testing a calculator service, emphasizing the interaction with external services and the use of junit. it discusses testing addition and multiplication operations, expecting the output to be 10 when 2 and 3 are passed as input.', 'chapters': [{'end': 101.854, 'start': 0.609, 'title': 'Implementing mockito for testing', 'summary': 'Covers implementing mockito for testing a calculator service, emphasizing the need for interaction with external services like cloud services or databases and the use of junit for testing.', 'duration': 101.245, 'highlights': ['The chapter emphasizes the need for interaction with external services like cloud services or databases when working with applications, highlighting the importance of implementing Mockito for testing complex operations.', "It discusses the example of a Calculator service interacting with a cloud service and the use of JUnit for testing the service's methods, showcasing the testing of the 'add' method using assert equals.", "The chapter introduces the concept of using a 'perform' method instead of 'add' to simulate interaction with a cloud service, highlighting the importance of testing such interactions for complex operations."]}, {'end': 202.401, 'start': 101.854, 'title': 'Testing calculator service', 'summary': 'Discusses testing a calculator service by performing addition and multiplication operations on input values, expecting the result to be processed by a cloud service and then multiplied by a specified value, aiming for the output to be 10 when 2 and 3 are passed as input.', 'duration': 100.547, 'highlights': ['The chapter discusses testing a calculator service by performing addition and multiplication operations on input values, expecting the result to be processed by a cloud service and then multiplied by a specified value.', 'The expected output when 2 and 3 are passed as input is 10, as 2 plus 3 equals 5, and 5 multiplied by 2 equals 10.', 'The chapter emphasizes the desire to call the perform operation and test its functionality.']}], 'duration': 201.792, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HsQ9OwKA79s/pics/HsQ9OwKA79s609.jpg', 'highlights': ['The chapter emphasizes the need for interaction with external services like cloud services or databases when working with applications, highlighting the importance of implementing Mockito for testing complex operations.', 'The chapter discusses testing a calculator service by performing addition and multiplication operations on input values, expecting the result to be processed by a cloud service and then multiplied by a specified value.', "It discusses the example of a Calculator service interacting with a cloud service and the use of JUnit for testing the service's methods, showcasing the testing of the 'add' method using assert equals.", 'The expected output when 2 and 3 are passed as input is 10, as 2 plus 3 equals 5, and 5 multiplied by 2 equals 10.', "The chapter introduces the concept of using a 'perform' method instead of 'add' to simulate interaction with a cloud service, highlighting the importance of testing such interactions for complex operations.", 'The chapter emphasizes the desire to call the perform operation and test its functionality.']}, {'end': 551.326, 'segs': [{'end': 302.838, 'src': 'embed', 'start': 252.995, 'weight': 1, 'content': [{'end': 255.357, 'text': 'how can we create object of calculator service?', 'start': 252.995, 'duration': 2.362}, {'end': 255.677, 'text': 'so what?', 'start': 255.357, 'duration': 0.32}, {'end': 265.444, 'text': "we have an option, as we actually have to call the cloud service, but then for testing it doesn't make sense, right.", 'start': 255.677, 'duration': 9.767}, {'end': 268.346, 'text': 'so normally what we do is we create a stub now?', 'start': 265.444, 'duration': 2.902}, {'end': 269.287, 'text': 'what is stub?', 'start': 268.346, 'duration': 0.941}, {'end': 271.468, 'text': 'stub is basically a fake object.', 'start': 269.287, 'duration': 2.181}, {'end': 278.754, 'text': 'now, when I say fake object what it means for testing, we have to create a fake object of calculator service.', 'start': 271.468, 'duration': 7.286}, {'end': 285.361, 'text': 'Now, just to make it more effective, I will say I will get the object of service using a constructor.', 'start': 279.514, 'duration': 5.847}, {'end': 290.988, 'text': 'So I will say calculator and here I will get the object of calculator service.', 'start': 286.242, 'duration': 4.746}, {'end': 292.61, 'text': 'I will name this as service itself.', 'start': 291.008, 'duration': 1.602}, {'end': 302.838, 'text': 'So whoever creates the object of calculator, he will provide me the object of service.', 'start': 294.252, 'duration': 8.586}], 'summary': 'Creating a fake object of calculator service for testing using a stub.', 'duration': 49.843, 'max_score': 252.995, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HsQ9OwKA79s/pics/HsQ9OwKA79s252995.jpg'}, {'end': 414.88, 'src': 'embed', 'start': 386.669, 'weight': 0, 'content': [{'end': 390.912, 'text': 'so it says expected 10, but it was 0, at least the test.', 'start': 386.669, 'duration': 4.243}, {'end': 392.273, 'text': 'run, right.', 'start': 390.912, 'duration': 1.361}, {'end': 395.555, 'text': 'but the uh, the answer you got is wrong.', 'start': 392.273, 'duration': 3.282}, {'end': 398.878, 'text': 'so this is how you create a stub, a fake object.', 'start': 395.555, 'duration': 3.323}, {'end': 407.704, 'text': 'so sometime, when you want to test calc, a unit, you have to create a fake object of some other class which are dependent.', 'start': 398.878, 'duration': 8.826}, {'end': 409.996, 'text': 'there is one way.', 'start': 409.155, 'duration': 0.841}, {'end': 414.88, 'text': 'the another way of doing it is actually by using some framework.', 'start': 409.996, 'duration': 4.884}], 'summary': 'Test expected 10, but got 0. creating a fake object for testing dependencies.', 'duration': 28.211, 'max_score': 386.669, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HsQ9OwKA79s/pics/HsQ9OwKA79s386669.jpg'}, {'end': 471.03, 'src': 'embed', 'start': 434.274, 'weight': 3, 'content': [{'end': 435.694, 'text': 'How do we get the dependency??', 'start': 434.274, 'duration': 1.42}, {'end': 437.375, 'text': "It's very simple.", 'start': 436.354, 'duration': 1.021}, {'end': 446.417, 'text': 'just go to maven repository, which is mbn repository, and search for mockito and It will give you the first link, mockito code.', 'start': 437.375, 'duration': 9.042}, {'end': 448.258, 'text': 'click on that.', 'start': 446.417, 'duration': 1.841}, {'end': 449.938, 'text': 'You can take any version.', 'start': 448.258, 'duration': 1.68}, {'end': 455.525, 'text': 'or let me go with the safe one, which is 2.8.9.', 'start': 449.938, 'duration': 5.587}, {'end': 459.627, 'text': 'I hope it will work and I will copy this, or okay, is it copied here?', 'start': 455.526, 'duration': 4.101}, {'end': 462.148, 'text': "it is copied and let's paste it here now.", 'start': 459.627, 'duration': 2.521}, {'end': 471.03, 'text': 'once you do that, you can see in your maven dependencies it will add the mockito dependency as well and you can see we got mockito dependency.', 'start': 462.148, 'duration': 8.882}], 'summary': 'Get mockito dependency from maven repository, version 2.8.9, added to maven dependencies.', 'duration': 36.756, 'max_score': 434.274, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HsQ9OwKA79s/pics/HsQ9OwKA79s434274.jpg'}, {'end': 505.637, 'src': 'embed', 'start': 480.907, 'weight': 4, 'content': [{'end': 488.99, 'text': "Now first of all CalculatorService is an interface and mockito says hey don't worry you can simply use a static method called as mock.", 'start': 480.907, 'duration': 8.083}, {'end': 497.434, 'text': 'So mock is a method belongs to mockito class and you just have to pass a type which is Calculator here.', 'start': 489.631, 'duration': 7.803}, {'end': 500.755, 'text': 'So CalculatorService dot class.', 'start': 497.974, 'duration': 2.781}, {'end': 503.296, 'text': 'Once you mention that it will give you the object.', 'start': 501.295, 'duration': 2.001}, {'end': 504.896, 'text': 'Can you see that? There is no error here.', 'start': 503.316, 'duration': 1.58}, {'end': 505.637, 'text': "It's so simple.", 'start': 505.077, 'duration': 0.56}], 'summary': "Mockito's mock method simplifies creating mock objects for interfaces like calculatorservice.", 'duration': 24.73, 'max_score': 480.907, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HsQ9OwKA79s/pics/HsQ9OwKA79s480907.jpg'}, {'end': 558.486, 'src': 'embed', 'start': 530.141, 'weight': 5, 'content': [{'end': 533.321, 'text': "now, if you're thinking do we are only testing calcutta?", 'start': 530.141, 'duration': 3.18}, {'end': 535.342, 'text': 'we are not testing calcutta service.', 'start': 533.321, 'duration': 2.021}, {'end': 536.902, 'text': 'who will test this?', 'start': 535.342, 'duration': 1.56}, {'end': 538.863, 'text': 'as i mentioned, this will be a cloud service.', 'start': 536.902, 'duration': 1.961}, {'end': 544.304, 'text': 'so whoever providing with the cloud service he i mean there it is their responsibility to test this cloud service.', 'start': 538.863, 'duration': 5.441}, {'end': 549.465, 'text': "it's not our responsibility, right, but we have to imagine that it works.", 'start': 544.304, 'duration': 5.161}, {'end': 551.326, 'text': 'now, question arise how can i make it work?', 'start': 549.465, 'duration': 1.861}, {'end': 558.486, 'text': "let's say I will inform my Mockito framework that hey, Mockito, you are doing a great job here.", 'start': 552.403, 'duration': 6.083}], 'summary': 'Testing calcutta service is not our responsibility, but we need to ensure it works, and we can do so by informing the mockito framework.', 'duration': 28.345, 'max_score': 530.141, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HsQ9OwKA79s/pics/HsQ9OwKA79s530141.jpg'}], 'start': 202.401, 'title': 'Unit testing and mockito framework', 'summary': 'Discusses the importance of creating fake objects in unit testing, like stubs, and emphasizes the usage of mockito framework for creating mock objects and managing dependencies, with a focus on simulating dependencies and the process of adding mockito dependency using maven repository.', 'chapters': [{'end': 363.976, 'start': 202.401, 'title': 'Unit testing and creating fake objects', 'summary': 'Discusses the importance of creating fake objects, like stubs, in unit testing to simulate dependencies, and the process of creating a fake object of a service to enable testing, with emphasis on the need for creating a fake object and its role in testing.', 'duration': 161.575, 'highlights': ['Creating a fake object, like a stub, is essential in unit testing to simulate dependencies and enable testing. Emphasizes the importance of creating a fake object, like a stub, to simulate dependencies and enable testing. It highlights the need for creating a fake object to test the functionality of the application.', "The need to create a fake object of a service in order to test the application's functionality, emphasizing the importance of simulating dependencies in testing. Stresses the significance of creating a fake object of a service to enable testing of the application's functionality, emphasizing the need to simulate dependencies in testing.", 'The process of utilizing a constructor to obtain the object of calculator service and the significance of passing the object as a dependency. Explains the process of using a constructor to obtain the object of calculator service and highlights the significance of passing the object as a dependency for testing.']}, {'end': 551.326, 'start': 363.976, 'title': 'Mockito framework and dependency management', 'summary': 'Discusses the usage of mockito framework for creating fake objects and managing dependencies, emphasizing the process of adding the mockito dependency using maven repository and creating a mock object for calculatorservice.', 'duration': 187.35, 'highlights': ['The chapter discusses the process of adding the Mockito dependency using Maven repository to manage dependencies, emphasizing the simplicity of obtaining the dependency and its addition to the project. The process of adding the Mockito dependency using Maven repository simplifies the process of obtaining and adding the dependency, providing a straightforward approach to dependency management.', "The use of Mockito framework for creating fake objects is explained, showcasing the simplicity of creating a mock object for CalculatorService using the 'mock' method, enabling efficient testing. The usage of Mockito framework for creating fake objects is exemplified by the straightforward process of creating a mock object for CalculatorService using the 'mock' method, facilitating efficient testing.", 'The responsibility of testing the cloud service is mentioned, highlighting that the testing of the cloud service is not the responsibility of the current unit testing process, but rather the responsibility of the cloud service provider. The responsibility of testing the cloud service is emphasized, clarifying that the current unit testing process does not include testing the cloud service, as it is the responsibility of the cloud service provider.']}], 'duration': 348.925, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HsQ9OwKA79s/pics/HsQ9OwKA79s202401.jpg', 'highlights': ['Emphasizes the importance of creating a fake object, like a stub, to simulate dependencies and enable testing.', "Stresses the significance of creating a fake object of a service to enable testing of the application's functionality.", 'Explains the process of using a constructor to obtain the object of calculator service and highlights the significance of passing the object as a dependency for testing.', 'The process of adding the Mockito dependency using Maven repository simplifies the process of obtaining and adding the dependency, providing a straightforward approach to dependency management.', "The usage of Mockito framework for creating fake objects is exemplified by the straightforward process of creating a mock object for CalculatorService using the 'mock' method, facilitating efficient testing.", 'The responsibility of testing the cloud service is emphasized, clarifying that the current unit testing process does not include testing the cloud service, as it is the responsibility of the cloud service provider.']}, {'end': 1132.257, 'segs': [{'end': 598.404, 'src': 'embed', 'start': 552.403, 'weight': 0, 'content': [{'end': 558.486, 'text': "let's say I will inform my Mockito framework that hey, Mockito, you are doing a great job here.", 'start': 552.403, 'duration': 6.083}, {'end': 561.968, 'text': 'so you are creating a fake object here and is working for me.', 'start': 558.486, 'duration': 3.482}, {'end': 564.57, 'text': 'but I also want to pass my test right.', 'start': 561.968, 'duration': 2.602}, {'end': 567.151, 'text': 'you can see we have a green line here.', 'start': 564.57, 'duration': 2.581}, {'end': 576.216, 'text': 'how can you make sure that your Mockito understand that when you are calling this, perform by passing 2 and 3, it will be calling.', 'start': 567.151, 'duration': 9.065}, {'end': 579.937, 'text': 'it will be calling this method, which is add and I want the answer for this,', 'start': 576.216, 'duration': 3.721}, {'end': 587.14, 'text': "because if I don't get the answer for this of how can I test the application right and okay?", 'start': 579.937, 'duration': 7.203}, {'end': 588.48, 'text': 'so how can we do that?', 'start': 587.14, 'duration': 1.34}, {'end': 595.423, 'text': 'so what option marketer provides is our market says okay, you want to make this test pass right with some values.', 'start': 588.48, 'duration': 6.943}, {'end': 596.563, 'text': 'you can do that.', 'start': 595.423, 'duration': 1.14}, {'end': 598.404, 'text': 'I will provide you an option of when.', 'start': 596.563, 'duration': 1.841}], 'summary': 'Using mockito, ensure accurate testing with when() method for passing specific values.', 'duration': 46.001, 'max_score': 552.403, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HsQ9OwKA79s/pics/HsQ9OwKA79s552403.jpg'}, {'end': 666.307, 'src': 'embed', 'start': 631.02, 'weight': 1, 'content': [{'end': 632.302, 'text': "but then let's use static import.", 'start': 631.02, 'duration': 1.282}, {'end': 636.946, 'text': 'I will say mockito, dot, mockito, dot, star.', 'start': 632.302, 'duration': 4.644}, {'end': 642.012, 'text': "so I will say I will import all the static classes so that I don't have to mention every time.", 'start': 636.946, 'duration': 5.066}, {'end': 645.135, 'text': "in fact, if you import statically, you don't have to mention mockito as well.", 'start': 642.012, 'duration': 3.123}, {'end': 648.883, 'text': 'you can simply say mock and you can see the when is working now.', 'start': 645.135, 'duration': 3.748}, {'end': 650.503, 'text': 'so we will say then return.', 'start': 648.883, 'duration': 1.62}, {'end': 655.584, 'text': 'so when you add two numbers, when you say 2,3, it will return 5.', 'start': 650.503, 'duration': 5.081}, {'end': 659.125, 'text': "you might be thinking we are hard coding it and that's fine, right.", 'start': 655.584, 'duration': 3.541}, {'end': 666.307, 'text': 'anyway, we know that this service, which is a cloud service, when you pass 2 and 3, it will return 5.', 'start': 659.125, 'duration': 7.182}], 'summary': 'Demonstrating static import for mockito; mocking behavior to return 5 when adding 2 and 3.', 'duration': 35.287, 'max_score': 631.02, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HsQ9OwKA79s/pics/HsQ9OwKA79s631020.jpg'}, {'end': 1057.32, 'src': 'heatmap', 'start': 1029.733, 'weight': 1, 'content': [{'end': 1034.214, 'text': 'and if you run this, oh, something went wrong.', 'start': 1029.733, 'duration': 4.481}, {'end': 1041.182, 'text': 'it says here null pointer exception, right, because when you use annotation we just have to use because, say,', 'start': 1034.214, 'duration': 6.968}, {'end': 1045.708, 'text': 'mockito is a different framework and we are using that in JUnit right.', 'start': 1041.182, 'duration': 4.526}, {'end': 1051.414, 'text': 'so to mention that we have to specify a rule again, this is not compulsory.', 'start': 1045.708, 'duration': 5.706}, {'end': 1053.916, 'text': 'okay, you can simply use that mock method.', 'start': 1051.414, 'duration': 2.502}, {'end': 1057.32, 'text': 'but in case, if you are looking for annotation, this is how you do it.', 'start': 1053.916, 'duration': 3.404}], 'summary': 'Using mockito in junit requires specifying rules for annotations to avoid null pointer exceptions.', 'duration': 27.587, 'max_score': 1029.733, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HsQ9OwKA79s/pics/HsQ9OwKA79s1029733.jpg'}], 'start': 552.403, 'title': 'Using mockito for unit testing', 'summary': "Explains how to use mockito for test automation and unit testing, covering the use of 'when' to specify behavior for method calls, static imports for simplifying the syntax, testing the perform method, verifying the usage of mock service, and creating mock objects using mockito and junit.", 'chapters': [{'end': 650.503, 'start': 552.403, 'title': 'Using mockito for test automation', 'summary': "Explains how to use mockito for test automation, covering the use of 'when' to specify behavior for method calls and the use of static imports for simplifying the syntax. it also mentions passing specific values to methods for testing.", 'duration': 98.1, 'highlights': ["Mockito provides the 'when' option to specify behavior for method calls, such as returning specific values for given inputs, ensuring the test passes with the desired values.", "Using static imports in Mockito simplifies the syntax, allowing direct usage of 'mock' and 'when' without explicitly mentioning 'Mockito'.", 'The importance of getting the answer from the method call is highlighted as essential for testing the application, emphasizing the need to ensure proper functionality through testing.']}, {'end': 1132.257, 'start': 650.503, 'title': 'Unit testing with mockito', 'summary': 'Discusses unit testing with mockito, including testing the perform method, verifying the usage of mock service, and creating mock objects using mockito and junit.', 'duration': 481.754, 'highlights': ['Mockito allows testing the perform method by passing specific values and verifying its behavior. The tutorial emphasizes testing the perform method by passing specific values such as 2 and 3 and verifying its behavior, ensuring that it returns the expected result.', "Verification of the usage of mock service using Mockito's verify method. The usage of the verify method in Mockito to confirm the invocation of the mock service by passing specific values, ensuring that the mock service is actually being utilized in the application.", 'Creation of mock objects using Mockito and JUnit. The explanation of creating mock objects using Mockito and JUnit, either by using the mock method or by using the @Mock annotation with MockitoRule, enabling the creation of mock services for testing.']}], 'duration': 579.854, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/HsQ9OwKA79s/pics/HsQ9OwKA79s552403.jpg', 'highlights': ["Mockito provides the 'when' option to specify behavior for method calls, ensuring the test passes with the desired values.", "Using static imports in Mockito simplifies the syntax, allowing direct usage of 'mock' and 'when' without explicitly mentioning 'Mockito'.", 'The importance of getting the answer from the method call is highlighted as essential for testing the application.']}], 'highlights': ['The chapter emphasizes the need for interaction with external services like cloud services or databases when working with applications, highlighting the importance of implementing Mockito for testing complex operations.', 'The chapter discusses testing a calculator service by performing addition and multiplication operations on input values, expecting the result to be processed by a cloud service and then multiplied by a specified value.', "The chapter introduces the concept of using a 'perform' method instead of 'add' to simulate interaction with a cloud service, highlighting the importance of testing such interactions for complex operations.", 'The chapter emphasizes the desire to call the perform operation and test its functionality.', 'The expected output when 2 and 3 are passed as input is 10, as 2 plus 3 equals 5, and 5 multiplied by 2 equals 10.', 'The process of adding the Mockito dependency using Maven repository simplifies the process of obtaining and adding the dependency, providing a straightforward approach to dependency management.', "The usage of Mockito framework for creating fake objects is exemplified by the straightforward process of creating a mock object for CalculatorService using the 'mock' method, facilitating efficient testing.", "Mockito provides the 'when' option to specify behavior for method calls, ensuring the test passes with the desired values.", "Using static imports in Mockito simplifies the syntax, allowing direct usage of 'mock' and 'when' without explicitly mentioning 'Mockito'.", 'The importance of getting the answer from the method call is highlighted as essential for testing the application.']}