Mockito Mock Method Return

I need to test the InvoiceAction. For example, a mock, fake, or stub method implementation between the two ends of the complexity spectrum might contain assertions to examine the context of each call. Mockito argument methods are defined in org. Below an example of test. What are Mocks and Spies? Both Mocks and Spies are the types of test doubles, which are helpful in writing unit tests. The base class JavaOSGiTest sets up a bundle context and has convenience methods for registering mocks as OSGi services and the retrieval of registered OSGi. copyright 2008 trainologic LTD Stubbing and Mocking • Mediator Objects and Testing • Stubs • Mocking Objects • Mockito • PowerMockito 3. However, in my production code there is a lot that I need to Mock away that is then used in more method calls. For example, a mock object might assert the order in which its methods are called, or assert consistency of data across method calls. With a Mockito mock, by default, any method call on the object will do nothing and return the default value for the method's return type. Mockito Junit Code Examples Mockito is an unwrap source testing framework for Java released under the MIT License. Moreover, all Mockito methods used for configuring a mock are also applicable to configuring a spy. How to mock methods with void return type? I implemented an observer pattern but I can't mock it with Mockito because I don't know how. Since this private method is inside your class under test then mocking it is little more specific. database, network locations etc. Use Mockito’s thenCallRealMethod () to Call a Real Method. answers package. This means that the discount method will just return 0 (so-called partial mocks are a workaround). Now we are ready to see what else can be done with mockito. use below:. Mocking URL with mockito. The scope of the mock is different from the mocks for final and static methods. methodName (); or if you want to combine it with follow-up behavior,. PowerMock is a JUnit extension the leverages the possibilities of EasyMock and Mockito to mock static methods (and much more). I need to test the InvoiceAction. Therefore it is a good idea to mock the service so it can respond fast and return expected results. com In this short tutorial, we focus on mocking void methods with Mockito. x, you'll get the following error: Mockito cannot mock/spy following: - final classes - anonymous classes - primitive types. You need to tell Mockito, whether you want to mock the method call or you want to call the real method. Search Google; About Google; Privacy; Terms. This will make userRepository. BDD Mockito Syntax. The most of the Mockito facilities are static methods of org. Mocking simulates the existence and behavior of a real object, allowing software engineers to test code in various hypothetical scenarios without the need to resort to countless system calls. Mockito is a powerful mock/stub library for unit tests in Java. ) Mock A mock is a "simulator" or a double of another object. • Mockito takes a different approach from the test presented previously. All the examples in this article use static methods. public class BaseController { public void method() { validate(); // I don't want to run this!. Classes needed to be defined using this annotation are typically those that needs to be byte-code manipulated. Spies are rarely used compared to mocks, but you may find them useful for testing legacy code that cannot be refactored, where testing it requires partial mocking. Mockito doesn't mock final methods so the bottom line is: when you spy on real objects + you try to stub a final method = trouble. equals (username, user. findUser (username). IsAny< string >()). Adding mockito as dependency to the project. Step 05 : Stubbing variations with Mockito. Now, our entity is a mock we can stub method isNew(). The trick with void methods is that Mockito assumes that they do nothing … - Selection from Mockito Cookbook [Book]. // can be used by unit test by Mocking it. OngoingStubbing. MockSettings object directly to the mock method: val settings = org. The nice thing about Mockito is that it allows creating mock objects of both interfaces and classes without forcing any explicit declarations. Behavior Driven Development style of writing tests uses //given //when //then comments as fundamental parts of your test methods. I'd like to validate the parameters passed to DriverManager. anyInt(), Mockito. My requirement was that I wanted to return true first time when hasNext() method and return false in the second iteration. A programmer typically creates a mock object to test the behaviour of some other object, in much the same way that a car designer uses a crash test dummy to simulate the dynamic behaviour of a human in vehicle impacts. Is there a good way to mock/verify this specific use-case. This class has no equals() method implemented and I had to keep it in a method's. ScalaTest provides just enough syntax sugar for the three most popular Java mocking frameworks—JMock, EasyMock, and Mockito—to remove boilerplate and clarify the client code. Here is a test class, mocking the behaviour of SampleClass, and setting up the test so that calls to the void method setDefaultValue are actually called, and subsequently verified with mockito. That is, there's nothing to return. spy instead. mock(PluginLicense. Mocks and Spies in Mockito were explained in detail in our previous tutorial of detailed Mockito training series. Mocking complex scenarios - Use PowerMock. Mock private method. The canonical reference for building a production grade API with Spring. You have to use spy. One would think why are void methods so special, that we need a post to explain them? Well thats because they are void methods. You mock a bomb to test the detonator. Now mocking the service's Save method is a bit different since it's a void method. These mock testing frameworks effectively "fake" some external dependencies, so that the object being tested has a consistent interaction with its. What are Mocks and Spies? Both Mocks and Spies are the types of test doubles, which are helpful in writing unit tests. The verification is quite simple: check whether or not a method of the mock is called. Unlike creating actual object, Mockito allows creation of fake object (external dependencies) which allows it to give consistent results to a given invocation. another mocking frameworks when you want to mock avoid. Sometimes it's useful to have a mock object return pre-defined output for certain inputs. Mockito : how to verify method was called on an object created within a method? With PowerMock you can cause it to return a mock from the call to the constructor. mock(), the order of method calls is not checked. A mock frameworks allow to create mock object as simple as possible. Mocks are a full replacement for dependency and can be programmed to return the specified output whenever a method on the mock is called. When we try to mock a final method, as we normally mock other methods, it is not mocke. Mocking URL with mockito. Mockito allows creation of mock object for the purpose of Test Driven Development and Behavior Driven development. Moreover, all Mockito methods used for configuring a mock are also applicable to configuring a spy. To put it all together, let’s write a simple test to show usage. Three ways to mock the void method: 1. class, RETURNS_MOCKS); Every method on the mocked object will return another mock. Create Spring ContextConfiguration Java class to specify base packages for component scanning Create UsersServiceImplTest class, Autowire service class, mock objects, call saveUser method and Assert expected results. Answer Wiki. Mockito doesn't mock final methods so the bottom line is: when you spy on real objects + you try to stub a final method = trouble. You can vote up the examples you like and your votes will be used in our system to generate more good examples. We use JUnit, Mockito, MockMvc to Unit test Spring MVC Rest Service. Recently I was writing a unit test which involves stubbing a non-void method that manipulates the given parameter. In some cases, you may need to alter the behavior of private method inside the class you are unit testing. Step 06 : Introduction to BDD. Im fairy new with mockito and am trying to write a test is return a mock that object as such that I can get it to sort of mock the checkStrategyName method?. The correct value is 0. It is impossible to mock final classes or static methods. Which means we can stub a method to return a specific object. In this tutorial, we will learn the concept of Mocks and Spies in Mockito. The code looked a bit like:. Here is a test class, mocking the behaviour of SampleClass, and setting up the test so that calls to the void method setDefaultValue are actually called, and subsequently verified with mockito. Below an example of test. Use Mockito to return the Application instance when FacesContext. Step 05 : Stubbing variations with Mockito. Change method to non-final (remove final keyword) and test it standard way. Testing Spring components with Mockito Be able to unit test your spring components without the need of loading the full spring-context with its ad-hoc test configurations it is ,in my opinion, a great advantage because it's clean, easy to maintain, faster to write, smooth to alter. validate() (only method) , leave other methods (getage() must return 20). Oct 28, 2016 · Consider a method signature like: public String myFunction(String abc); Can Mockito help return the same string that the method received?. getConnection, but I have no idea about how to mock a static method. i have called 2 levels to test that number junit test for void methods using mockito. Hurrah!!! Lets use Mockito to mock TodoService. public class BaseController { public void method() { validate(); // I don't want to run this!. 0 this method will perform a type check thus null values are not authorized. Using the Mockito library we’ll mock the loginRepository and ask it to return a User object on which we’ll make our assertions. Mockito uses equals() to compare arguments by default, as in: This works well when comparing Strings, Integeretc, but breaks down when the argument is an instance of a class which does not override the Object's equals() method, such as a Throwable: Two possible solutions in that case: First method - using an argument captor Second…. Sometimes it's useful to have a mock object return pre-defined output for certain inputs. 5) Using Mockito spying in order to mock static methods. Mock static method Refactoring considerations. Oct 28, 2016 · Consider a method signature like: public String myFunction(String abc); Can Mockito help return the same string that the method received?. In Mockito, a side effect happens to the real method invocation. For example, we can mock a Spring Data JPA repository in a service class to stub a getProduct() method of the repository to return a Product object. Returns(true); The need for this is subtle, and lies in the fact that the Expect method is not receiving a lambda expression, unlike the strong-typed version, and the alternatives were far worse. Creating the mock like this will return defaults for all methods that have not been mocked. This is because the scope of the mocks is limited to the test method where they are specified. i have called 2 levels to test that number junit test for void methods using mockito. The verify() method is used to verify that the mocked out method was actually called. Update dependencies to Mockito 2. This document shows how to do common mocking tasks in Java using both jMock and EasyMock. Mockito doesn’t give you hangover because the tests are very readable and they produce clean verification errors. To understand this, you need to know when a real method invocation happens. We’ll use Mockito in this example to mock configure simple return behavior in a mocked DAO class. The code in question did not lend itself to nice and easy testing, but leveraging a lesser-used bit of Mockito functionality helped make the code better. 1 Mockito是什么? Mockito是mocking框架,它让你用简洁的API做测试。而且Mockito简单易学,它可读性强和验证语法简洁。 1. Static methods mocking with Mockito. You can use methods like anyInt() of class org. It gives a lot of power into the hands of developers, but at the same time does not corrupt their hearts! Instead it urges them to write clean, well-designed and loosely-coupled code. Let's look at the first example of a typical spying use case where we have that problematic usage of a static method that we cannot mock. i have called 2 levels to test that number junit test for void methods using mockito. unit testing - Get java. What will happen is the real method will be called *on mock* but *not on the real instance* you passed to the spy() method. Warning 2:. This implementation is due static type safety imposed by java compiler. Mocking static methods in JUnit using PowerMock. mock(), the order of method calls is not checked. config for Maven, JUnit, PowerMock, EasyMock, and Mockito. Void methods can be used with Mockito’s doNothing(), doThrow(), and doAnswer() methods, making mocking and verifying intuitive: However, doNothing() is Mockito’s default behavior for void methods. Cannot mock static methods; Cannot mock constructors; Cannot mock equals(), hashCode(). Methods with return values can be tested by asserting the returned value, but how to test void methods? The void method that you want to test could either be calling other methods to get things done or processing the input parameters or maybe generating some values or all of it Mockito test method void. thenReturn(true); when is a static method of the Mockito class. @VisibleForTesting: MySingletonClass {}. When you call a method of the mock object, it returns a specified value but it doesn’t do anything you defined in the class. If you miss @Singleton, then in runtime, there will be two instances of Client class. The Scope of Regular Mockito Mocks. the mock behavior in this method. Unlike creating actual object, Mockito allows creation of fake object (external dependencies) which allows it to give consistent results to a given invocation. A few mockito examples mocking List class : Multiple return values, Argument Matchers and throwing exceptions. We will also learn about stubbing void methods with Mockito. java with public method called Send(String parameter). If you remember, from my earlier post, the syntax of stubbing any method with a non void return type is as follows. These kind of applications, as we all know it, are rare. Originally, the tests created a test double for the builder object and then stubbed all of the methods on the builder to return the builder double itself. Mockito cheat sheet code. Throughout, I use the terminology defined by Gerard Meszaros in his book xUnit Test Patterns. It's a little different in Mockito and. createStrictMock(), the order of execution of the method does matter. However microservices-based systems require a different test strategy that involves component testing , in which case the dependencies that you need to mock are HTTP endpoints. I'm using JUnit 4 and Mockito for my test cases. Matcher methods like anyObject(), eq() do not return matchers. Above when we mocked we used the thenReturn after calling when. In case you are new to Mockito, it is an open source mock unit testing framework for Java. The foreach loop internally uses two methods on the iterator returned by the set's iterator () method: hasNext () and next (). Mockito has a whole lot more features that allow for mocking, matching arguments and verifying method calls. mockito void method verify (8). For example, Mockito. As with other articles focused on the Mockito framework (like Mockito Verify, Mockito When/Then, and Mockito's Mock Methods) the MyList class shown below will be used as the collaborator in test cases. With the recent release of version 2, one of the big changes is the ability to mock the un-mockable. From compiler point of view, it is only Java code, that should be checked for safety and correctness before compiling. All methods which are not explicitly instrumented via one of the Mockito when, doCallRealMethod, doThrow (and so on) methods will do nothing (and return null if they have a return value). The OP asked if you could mock() instead of spy(), and the answer is YES: you could do that to solve the same problem potentially. Mockito is a powerful mock/stub library for unit tests in Java. Mockito on Android step-by-step Published May 15, 2012 Software Engineering 19 Comments One of my biggest frustrations with writing code for Android has been the fact that none of the current Java mocking frameworks work on Android’s Dalvik VM. Finally, you will explore the concept of partial mocks and how to use them to test tricky situations. 8+) implements a "spy" feature which doesn't mock the object, it creates a "spy" wrapper around the real method implementations. Following is an example. All methods which are not explicitly instrumented via one of the Mockito when, doCallRealMethod, doThrow (and so on) methods will do nothing (and return null if they have a return value). Following is an example. doThrow() if you want to throw an exception from the mocked void method. You can vote up the examples you like and your votes will be used in our system to generate more good examples. Mockito makes the testing job easier. getResourceBundle 3. In this article, we will see an example of a mock object that is not stubbed and then call methods that return values to see what would be their default values. Mock static method Refactoring considerations. For example, you can verify that a method has been called with certain parameters. Mocking return values of static methods. The same cannot be said for static methods. i have mocked required object for testing void method. Mockito is a popular open source Java mocking framework. getConnection, but I don't know how to mock a static method. I'm fascinated by how easy it is to use, compared to other things out there both in the Java and. Step 07 : How to verify calls on a mock? Verify how many times a method is. Sometimes it's useful to have a mock object return pre-defined output for certain inputs. Examples are using Mockito and PowerMock mocking frameworks and TestNG unit testing framework. A few mockito examples mocking List class : Multiple return values, Argument Matchers and throwing exceptions. PluginLicense pluginLicense = Mockito. Mockito Junit Code Examples Mockito is an unwrap source testing framework for Java released under the MIT License. PowerMockito is capable of testing private, final or static methods as it makes use of Java Reflection API. getComputedValue(), we are actually executing a stub API from the mock object that doesn’t do anything but to return a default value, which is 0. I have been using Mockito for a project recently and made a cheat sheet that is meant to be easy to digest. MockSettings class. Answer Wiki. Call the method under test ,which is isTradeValid() and assert to validate the result 4. Mockito is an Open Source Mocking framework in Java and provides easy ways to create test doubles, also referred to as mocks in further writing. So, here comes another post on how to mock/stub void methods using PowerMock. As you can see, we've used the method times to specify the number of times we expect the method to have been called during the test and any to tell Mockito that we don't care about the actual parameters passed in the method invocations. No mocking – In theory, static methods should be used only in small utility classes. This document shows how to do common mocking tasks in Java using both jMock and EasyMock. 10 – Junit has gone over some major tranformations in regards to the test runner. Usually I would create an instance of the class under test (ClassUnderTest) and stick my mocks via setter methods. The OP asked if you could mock() instead of spy(), and the answer is YES: you could do that to solve the same problem potentially. 2 为什么需要Mock. The Scope of Regular Mockito Mocks. Mockito to set the mock objects behaviour when it is called with any integer as argument. In simple terms, mock objects comes handy in situations like when you are testing a class [A] which depends on another class [B]. Mockito doesn't mock final methods so the bottom line is: when you spy on real objects + you try to stub a final method = trouble. Mocking library for TypeScript inspired by You can also stub method with your own implementation // You can specify return values as multiple. Examples are using Mockito and PowerMock mocking frameworks and TestNG unit testing framework. The HomePageTest class has also one test method called renderPage() which verifies that the home page is rendered correctly and that the interactions with the created mock object are. Mockito provides an API to raise errors during testing. How mock BindingResult in/with Mockito method should return false. Spring Boot Instead of using an @Autowired field for the bean in the test and a Configuration class that defines it, you can simply use a field for the bean and annotate it with @MockBean. Mockito makes mocking very easy. Mock will be created by Mockito. Mockito works in any environment and has no external dependencies; Drawbacks. I’m fascinated by how easy it is to use, compared to other things out there both in the Java and. A few mockito examples mocking List class : Multiple return values, Argument Matchers and throwing exceptions. Search Google; About Google; Privacy; Terms. Examples are using Mockito and PowerMock mocking frameworks and TestNG unit testing framework. Everytime i run this test the method return true. Powermock - A Brief Introduction. You could argue that in the case of mockito compiler won't need to bother about the casting of returned type because call of original method would not produce anything, but it is known by mockito. A mock frameworks allow to create mock object as simple as possible. Mockito is distributed. On a Mock Object returned by a EasyMock. No mocking - In theory, static methods should be used only in small utility classes. This is a time when JMockit leaves its consistent interface, simply because it cannot see private methods. Because by default spys, call real methods, calling first the stubbing do* or will* will allow mockito to tell the mock that a method will be stubbed. By mocking a method of a associated class, the method doesn’t get called, instead our preset return value is returned when invoked. Mock will be created by Mockito. Mockito - mock static methods for helper. mock(CustomerDao. Mockito on Android step-by-step Published May 15, 2012 Software Engineering 19 Comments One of my biggest frustrations with writing code for Android has been the fact that none of the current Java mocking frameworks work on Android’s Dalvik VM. Let's say you have a Person class that has external communication and return values accordingly. OK, I Understand. If you would like a strict Mock Object that checks the order of method calls, use EasyMock. In most cases, both plain arguments and argument matchers can be passed into mock methods:. x, you'll get the following error: Mockito cannot mock/spy following: - final classes - anonymous classes - primitive types. The mocked method is called in case of both mock and spy objects. This is a simple demonstration on how to use Mockito to mock external classes in a JUnit test. We test crud operations with corresponding GET, PUT, POST and DELETE request methods. Mockito uses equals() to compare arguments by default, as in: This works well when comparing Strings, Integeretc, but breaks down when the argument is an instance of a class which does not override the Object's equals() method, such as a Throwable: Two possible solutions in that case: First method - using an argument captor Second…. For example, a mock object might assert the order in which its methods are called, or assert consistency of data across method calls. Partial mocking helps in situations like this, where it can mock some of the method invocations and return whatever responses you want to provide instead of executing the dependent method themselves but still allowing the real implementations to be called for the rest. This document shows how to do common mocking tasks in Java using both jMock and EasyMock. 1, this is the correct line to add to your build. strictMock() to create it. For example, Mockito. In the code example below I am going to share with you how to call a real method of a mocked object using Mockito's thenCallRealMethod(). In line no. Mocking Java classes in Groovy vs Mockito 14 February, 2013 2 Comments While experimenting with using an ODF parser in Groovy, I was attempting to write unit tests in Groovy and mocking objects from the ODF parser library was required in my tests. Step 07 : How to verify calls on a mock? Verify how many times a method is. Which means we can stub a method to return a specific object. mock(AClass. SomeClass mock = Mockito. Because the controller has two dependencies ( RequestService and CommentValidator) injected into it through Spring autowiring, we are going to create these two mocks and inject them into the controller by annotating them with Mockito’s @Mock and @InjectMocks accordingly. doReturn() can also be used with methods that don’t return any value. They are no longer needed, just use PowerMockito. Since proxy pattern is created by extending it cannot mock static, private, final method, and constructor. method to return. It provides methods thenThrow(Throwable) and doThrow(Throwable), so one can stub the mock to throw an exception when the stubbed method is invoked. Here is a recap of the need: This is what I usually write to mock a method of a real object (usually to return a mock):. Now to create the favorite controller test what you can do is use Ctrl. This means that the discount method will just return 0 (so-called partial mocks are a workaround). thenReturn (user); Assert. Java Mockito Mock Testing; Update MySQL version from 5. 7) You can create a mock with specified strategy for its. when (loginRepository. config for Maven, JUnit, PowerMock, PowerMockito, and Mockito Abstract I prev iously wr ote about Mocking return values of static methods. Mockito provides you with a listener whose responsibilities are as follows: Initialize mocks annotated with the @Mock annotation (it is done only once) Validate the usage of Mockito after each test method. I have been using Mockito for a project recently and made a cheat sheet that is meant to be easy to digest. Mockito to set the mock objects behaviour when it is called with any integer as argument. Mockito is a mocking framework, JAVA-based library that is used for effective unit testing of JAVA applications. Testing Spring components with Mockito Be able to unit test your spring components without the need of loading the full spring-context with its ad-hoc test configurations it is ,in my opinion, a great advantage because it's clean, easy to maintain, faster to write, smooth to alter. In this article (in french), I wrote 6 months ago, I was searching for a mockito-like syntax to stub only one method of an object instance under test. Lets use Mockito to mock TodoService. Add the created mock object to the mock application context. This is because the scope of the mocks is limited to the test method where they are specified. Use Mockito. doAnswer() : We can use this to perform some operations when a mocked object method is called that is returning void. Mockito doesn't give you hangover because the tests are very readable and they produce clean verification errors. mock child property job. This is a convenience method in the jMock library that means that I don't need to explicitly call verify later on, any mock created with the convenience method is automatically verified at the end of the test. Purpose: Unit testing…. First, you will learn how to use mock objects instead of real dependencies. Mocking Methods With Mockito. That is, there's nothing to return. although stubbed methods may return mocks, you cannot inline mock creation (mock()) call inside a thenReturn method (see issue 53). Mock some methods on an object. If available, go to IF branch in line 97 to return mocked data, or else return default answer, in my example I don't prepare any mocked data for getBook, so. As the linked document mentions (Point # 12) you can use any of the doThrow(),doAnswer(),doNothing(),doReturn() family of methods from Mockito framework to mock void methods. // can be used by unit test by Mocking it. In Mockito, we mock behavior, not implementation by adding a dummy functionality to a mock interface that can be used in unit testing. Just some methods of an object can be mocked using spy() of mockito. Mockito invokes this default constructor. Im fairy new with mockito and am trying to write a test is return a mock that object as such that I can get it to sort of mock the checkStrategyName method?. Spy - a mock created as a proxy to an existing real object; some methods can be stubbed, while the un- stubbed ones are forwarded to the covered object; Mockito is a mocking framework helpful in creating mocks and spies in a simple and intuitive way, while at the same time providing great control of the whole process. Mockito is a popular open source Java mocking framework. What about if you want to mock a constructor? The naïve approach is to try:. save() return the same user object that is passed into the method. Mockito to set the mock objects behaviour when it is called with any integer as argument. Example: @Mock(answer = RETURNS_DEEP_STUBS) UserProvider userProvider; This is not the full list of Answers available in Mockito. This implementation is due static type safety imposed by java compiler. Use Mockito’s thenCallRealMethod () to Call a Real Method. getConnection, but I don't know how to mock a static method. mock() is used to make a new class that has the same interface as the. In simple terms, mock objects comes handy in situations like when you are testing a class [A] which depends on another class [B]. ) Mock A mock is a "simulator" or a double of another object. Spies are rarely used compared to mocks, but you may find them useful for testing legacy code that cannot be refactored, where testing it requires partial mocking. Create a resource bundle using one of the ResourceBundle. In Mock JUnit tests with Mockito example post, I have shown how and why to use Mockito java mocking framework to create good unit tests. Let's assume the following setup: Our unit under test is the class Calculator which just delegates the addition of two integers to MathUtil which offers only static methods:. mock() is just another way to create a mock. You can vote up the examples you like and your votes will be used in our system to generate more good examples. Let’s look at how we can use Mockito methods to mock behaviour of the mock or spy objects we create. Also, notice the how the behaviour of method isEmpty() is mocked below. Mockito Tutorial (A comprehensive guide with examples) 20 May 2017 Mockito is a mocking framework for Java which is extremely easy to use, so this post will discuss all the cool features you need to know about mockito with simple and easy examples. save() return the same user object that is passed into the method. It is impossible to mock final classes or static methods. Matcher methods like anyObject(), eq() do not return matchers. It lets you write beautiful tests with clean & simple API. It provides methods thenThrow(Throwable) and doThrow(Throwable), so one can stub the mock to throw an exception when the stubbed method is invoked. The Mockito and PowerMockito frameworks provide for this, but the syntax isn't immediately obvious. I'd like to validate the parameters passed to DriverManager. So there shouldn’t be need to mock static method. This creates a new instance of AbstractBuild which returns FAILURE as build result. Mockito: using a method in "thenReturn" to return a mock doesn't work I have encountered what I assume might be a bug with Mockito, but was wondering if anyone else can shed light as to why this test doesn't work. Mockito - How to mock repository findById thenReturn() Optional? Try to mock a repository findById method, but no idea use thenReturn() to return an object,. Here's a trick I found on Stackoverflow to "mock" a superclass method to do nothing with mockito. mock(CustomerDao.