unit testing - What are mock objects in Java? -


I know what is duplicate items in Java. Why do we make them and what their Use?

Some object is used for a counterfeit object unit test, if you have objects whose By the ways you want to test, and those methods depend on any other object, you make a duplicate of dependence rather than the real example of that dependency. This allows you to check your object in isolation.

There is a general Java framework to create counterfeit goods and they generally allow you to create a mock object whose behavior you can define, so that when you call the methods on the counterfeit object Well know that (as the return value and side effects) expect.

For example, a common use case may be in an MVC application, where you have the DAO layer (Data Access Objects) and a controller that displays business logic if you use the unit controller If you want to check, and have dependency on the controller's DAO, then you can duplicate the DAO which will return the dummy object to your controller.

One thing that is important to note is that it is usually the case that imitation goods apply the same interface as the objects that they are joking - this is the interface type of your code. Allows them to deal with them, as if they are examples of the real thing.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -