{"id":10338,"date":"2013-03-25T19:00:12","date_gmt":"2013-03-25T17:00:12","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=10338"},"modified":"2013-03-25T16:28:34","modified_gmt":"2013-03-25T14:28:34","slug":"junit-and-easymock-cooperation","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2013\/03\/junit-and-easymock-cooperation.html","title":{"rendered":"JUnit and EasyMock cooperation"},"content":{"rendered":"<p>Developers always need to take care about code which they produced. They should be ensured that code works properly after a new feature was implemented or some bug was fixed. That\u2019s can be achieved at least with the help of unit tests. Since this blog is dedicated to Java programming language, today I will write the article about <b>JUnit 4.1 and EasyMock 3.<\/b>1 frameworks. The main purpose of these frameworks is to make writing of unit tests easier.<\/p>\n<h2>Introduction<\/h2>\n<p>For the demonstration of JUnit and EasyMock capabilities I need to have some code which I\u2019m going to cover with tests. So at the start I\u2019m going to introduce you a simple<br \/>\n&nbsp;<br \/>\napplication which I have developed for this tutorial. It should be very familiar for Java developers, because it emulates work of a coffee machine. Now I will describe in a few words functionality of the application. Coffee machine has two containers: for the water and for the coffee. You can make three varieties of coffee depends on portion size (small, medium, large).<\/p>\n<ul>\n<li>Positive scenario: you make a portion of coffee and containers have enough water and coffee beans.<\/li>\n<li>Negative scenario: you make a portion of coffee and containers haven\u2019t enough water or coffee beans.<\/li>\n<\/ul>\n<p>If any container isn\u2019t complete enough you can refill it. After the concise description of application\u2019s functionality you can easily imagine how it should work. It\u2019s time to provide code samples of classes.<\/p>\n<h2>Application code<\/h2>\n<p>Now try to be more patient and attentive. You will see a plenty of classes below, which I\u2019m going to test in the next paragraph. As was mentioned above, coffee machine can produce three types of coffee depends on portion size you want to get. Portions in the application will be represented as an enumeration.<\/p>\n<pre class=\" brush:java\">public enum Portion {\r\n\tSMALL(1), MEDIUM(2), LARGE(3);\r\n\r\n\tprivate int size;\r\n\r\n\tprivate Portion(int size) {\r\n\t\tthis.size = size;\r\n\t}\r\n\r\n\tpublic int size() {\r\n\t\treturn size;\r\n\t}\r\n}<\/pre>\n<p>Our coffee machine has two containers, that\u2019s mean we need to build logical architecture for them. Let\u2019s adhere to smart coding approaches based on interfaces.<\/p>\n<pre class=\" brush:java\">public interface IContainer {\r\n\r\n\tpublic boolean getPortion(Portion portion) throws NotEnoughException;\r\n\tpublic int getCurrentVolume();\r\n\tpublic int getTotalVolume();\r\n\tpublic void refillContainer();\r\n\r\n}<\/pre>\n<p>In order to avoid a code dublication I need to develop an abstract class for the container. In context of this programming approach I want to bethink one of my posts about <a title=\"Abstract class VS Interface\" href=\"http:\/\/fruzenshtein.com\/abstract-class-vs-interface\/\" target=\"_blank\">Abstract class VS Interface<\/a>.<\/p>\n<pre class=\" brush:java\">public abstract class AbstractContainer implements IContainer {\r\n\r\n\tprivate int containerTotalVolume;\r\n\tprivate int currentVolume;\r\n\r\n\tpublic AbstractContainer(int volume) {\r\n\t\tif (volume &lt; 1)\r\n\t\t\tthrow new IllegalArgumentException('Container's value must be greater then 0.');\r\n\t\tcontainerTotalVolume = volume;\r\n\t\tcurrentVolume = volume;\r\n\t}\r\n\r\n\t@Override\r\n\tpublic boolean getPortion(Portion portion) throws NotEnoughException {\r\n\t\tint delta = currentVolume - portion.size();\r\n\t\tif (delta &gt; -1) {\r\n\t\t\tcurrentVolume -= portion.size();\r\n\t\t\treturn true;\r\n\t\t} else\r\n\t\t\tthrow new NotEnoughException('Refill the '\r\n\t\t\t\t\t+ this.getClass().getName());\r\n\t}\r\n\r\n\t@Override\r\n\tpublic int getCurrentVolume() {\r\n\t\treturn currentVolume;\r\n\t}\r\n\r\n\t@Override\r\n\tpublic int getTotalVolume() {\r\n\t\treturn containerTotalVolume;\r\n\t}\r\n\r\n\t@Override\r\n\tpublic void refillContainer() {\r\n\t\tcurrentVolume = containerTotalVolume;\r\n\t}\r\n\r\n}<\/pre>\n<p>Methods in the Abstract Container are self explained, so there is no need to stop on them more detail. You probably noticed NotEnoughException, don\u2019t worry, it\u2019s nothing special, just custom specific exception for the application.<\/p>\n<pre class=\" brush:java\">public class NotEnoughException extends Exception {\r\n\r\n\tpublic NotEnoughException(String text) {\r\n\t\tsuper(text);\r\n\t}\r\n\r\n}<\/pre>\n<p>After development of container interface and abstract class were completed, we can proceed with concrete container realisation.<\/p>\n<pre class=\" brush:java\">public class CoffeeContainer extends AbstractContainer {\r\n\r\n\tpublic CoffeeContainer(int volume) {\r\n\t\tsuper(volume);\r\n\t}\r\n\r\n}<\/pre>\n<p>The same class will be for the water container:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<pre class=\" brush:java\">public class WaterContainer extends AbstractContainer {\r\n\r\n\tpublic WaterContainer(int volume) {\r\n\t\tsuper(volume);\r\n\t}\r\n\r\n}<\/pre>\n<p>Now we have all required stuff to develop code related to the coffee machine. As previously, I will start from interface development.<\/p>\n<pre class=\" brush:java\">public interface ICoffeeMachine {\r\n\r\n\tpublic boolean makeCoffee(Portion portion) throws NotEnoughException;\r\n\tpublic IContainer getCoffeeContainer();\r\n\tpublic IContainer getWaterContainer();\r\n\r\n}<\/pre>\n<p>And finally here is a realisation of coffee machine:<\/p>\n<pre class=\" brush:java\">public class CoffeeMachine implements ICoffeeMachine {\r\n\r\n\tprivate IContainer coffeeContainer;\r\n\tprivate IContainer waterContainer;\r\n\r\n\tpublic CoffeeMachine(IContainer cContainer, IContainer wContainer) {\r\n\t\tcoffeeContainer = cContainer;\r\n\t\twaterContainer = wContainer;\r\n\t}\r\n\r\n\t@Override\r\n\tpublic boolean makeCoffee(Portion portion) throws NotEnoughException {\r\n\r\n\t\tboolean isEnoughCoffee = coffeeContainer.getPortion(portion);\r\n\t\tboolean isEnoughWater = waterContainer.getPortion(portion);\r\n\r\n\t\tif (isEnoughCoffee &amp;&amp; isEnoughWater) {\r\n\t\t\treturn true;\r\n\t\t} else {\r\n\t\t\treturn false;\r\n\t\t}\r\n\t}\r\n\r\n\t@Override\r\n\tpublic IContainer getWaterContainer() {\r\n\t\treturn waterContainer;\r\n\t}\r\n\r\n\t@Override\r\n\tpublic IContainer getCoffeeContainer() {\r\n\t\treturn coffeeContainer;\r\n\t}\r\n\r\n}<\/pre>\n<p>That\u2019s it, what relates to the program which I\u2019m going to test with the help of unit tests.<\/p>\n<h2>JUnit testing<\/h2>\n<p>Before I start a JUnit tests development, I want to repeat canonical aims of unit tests. An unit test checks the smallest part of functionality \u2013 method or a class. This circumstance imposes some logical restrictions on a development. That\u2019s mean that you don\u2019t need to put some extra logic in a method, because after this it becomes more difficult for a testing. And one more important thing \u2013 unit testing implies an isolation of functionality from other parts of application. We don\u2019t need to check functionality of a method \u201cA\u201d while we are working with a method \u201cB\u201d. So let\u2019s stat to write JUnit tests for the coffee machine application. For this purpose we need to add some dependencies to the pom.xml<\/p>\n<pre class=\" brush:xml\">...\r\n\t\t&lt;dependency&gt;\r\n\t\t\t&lt;groupid&gt;org.easymock&lt;\/groupid&gt;\r\n\t\t\t&lt;artifactid&gt;easymock&lt;\/artifactid&gt;\r\n\t\t\t&lt;version&gt;3.1&lt;\/version&gt;\r\n\t\t&lt;\/dependency&gt;\r\n\t\t&lt;dependency&gt;\r\n\t\t\t&lt;groupid&gt;junit&lt;\/groupid&gt;\r\n\t\t\t&lt;artifactid&gt;junit&lt;\/artifactid&gt;\r\n\t\t\t&lt;version&gt;4.11&lt;\/version&gt;\r\n\t\t&lt;\/dependency&gt;\r\n...\r\n<\/pre>\n<p>I have choosen AbstractContainer class for the demonstration of JUnit tests. Because in context of the application we have two realisations of this class and if we will write tests for it, automaticaly we will test WaterContainer class and CoffeeContainer class.<\/p>\n<pre class=\" brush:java\">import static org.junit.Assert.assertEquals;\r\n\r\nimport org.junit.After;\r\nimport org.junit.Before;\r\nimport org.junit.Test;\r\n\r\nimport com.app.data.Portion;\r\nimport com.app.exceptions.NotEnoughException;\r\nimport com.app.mechanism.WaterContainer;\r\nimport com.app.mechanism.interfaces.IContainer;\r\n\r\npublic class AbstractContainerTest {\r\n\r\n\tIContainer waterContainer;\r\n\tprivate final static int VOLUME = 10;\r\n\r\n\t@Before\r\n\tpublic void beforeTest() {\r\n\t\twaterContainer = new WaterContainer(VOLUME);\r\n\t}\r\n\r\n\t@After\r\n\tpublic void afterTest() {\r\n\t\twaterContainer = null;\r\n\t}\r\n\r\n\t@Test(expected = IllegalArgumentException.class)\r\n\tpublic void testAbstractContainer() {\r\n\t\twaterContainer = new WaterContainer(0);\r\n\t}\r\n\r\n\t@Test\r\n\tpublic void testGetPortion() throws NotEnoughException {\r\n\t\tint expCurVolume = VOLUME;\r\n\r\n\t\twaterContainer.getPortion(Portion.SMALL);\r\n\t\texpCurVolume -= Portion.SMALL.size();\r\n\t\tassertEquals('Calculation for the SMALL portion is incorrect',\r\n\t\t\t\texpCurVolume, waterContainer.getCurrentVolume());\r\n\r\n\t\twaterContainer.getPortion(Portion.MEDIUM);\r\n\t\texpCurVolume -= Portion.MEDIUM.size();\r\n\t\tassertEquals('Calculation for the MEDIUM portion is incorrect',\r\n\t\t\t\texpCurVolume, waterContainer.getCurrentVolume());\r\n\r\n\t\twaterContainer.getPortion(Portion.LARGE);\r\n\t\texpCurVolume -= Portion.LARGE.size();\r\n\t\tassertEquals('Calculation for the LARGE portion is incorrect',\r\n\t\t\t\texpCurVolume, waterContainer.getCurrentVolume());\r\n\r\n\t}\r\n\r\n\t@Test(expected = NotEnoughException.class)\r\n\tpublic void testNotEnoughException() throws NotEnoughException {\r\n\t\twaterContainer.getPortion(Portion.LARGE);\r\n\t\twaterContainer.getPortion(Portion.LARGE);\r\n\t\twaterContainer.getPortion(Portion.LARGE);\r\n\t\twaterContainer.getPortion(Portion.LARGE);\r\n\t}\r\n\r\n\t@Test\r\n\tpublic void testGetCurrentVolume() {\r\n\t\tassertEquals('Current volume has incorrect value.', VOLUME,\r\n\t\t\t\twaterContainer.getCurrentVolume());\r\n\t}\r\n\r\n\t@Test\r\n\tpublic void testGetTotalVolume() {\r\n\t\tassertEquals('Total volume has incorrect value.', VOLUME,\r\n\t\t\t\twaterContainer.getTotalVolume());\r\n\t}\r\n\r\n\t@Test\r\n\tpublic void testRefillContainer() throws NotEnoughException {\r\n\t\twaterContainer.getPortion(Portion.SMALL);\r\n\t\twaterContainer.refillContainer();\r\n\t\tassertEquals('Refill functionality works incorectly.', VOLUME,\r\n\t\t\t\twaterContainer.getCurrentVolume());\r\n\t}\r\n\r\n}<\/pre>\n<p>I need to explain, for what all of annotations are used. But I\u2019m to lazy for this and I just give you a link to the <a title=\"JUnit API\" href=\"http:\/\/api.dpml.net\/junit\/4.2\/org\/junit\/package-summary.html\" target=\"_blank\">JUnit API<\/a>. There you can read the most correct explanations. Notice common things for all tests \u2013 they are all marked with @Test annotation, it indicates that a following method is a test, and every test ends with some of \u201c<em>assert<\/em>\u201d methods. Assertions are an essential part for each test, because all manipulations in a test should be checked in the end of it.<\/p>\n<h2>JUnit with EasyMock testing<\/h2>\n<p>Ok, in the previous paragraph I show you the example of sveral simple JUnit tests. In that example tests doesn\u2019t colaborate with any other classes. What if we need to involve some extra class in a JUnit test? I mentioned above that unit tests should be isolated from a rest application\u2019s functionality. For this purpose you can use <b>EasyMock testing framework<\/b>. With the help of EasyMock you can crate mocks. Mocks are objects which emulates behaviour of real concrete object, but with the one big plus, you can specify state for the mock, and in this way you obtain that state for the fake object which you need in particular moment of unit test.<\/p>\n<pre class=\" brush:java\">import static org.junit.Assert.*;\r\n\r\nimport org.easymock.EasyMock;\r\nimport org.junit.After;\r\nimport org.junit.Before;\r\nimport org.junit.Test;\r\n\r\npublic class CoffeeMachineTest {\r\n\r\n\tICoffeeMachine coffeeMachine;\r\n\tIContainer coffeeContainer;\r\n\tIContainer waterContainer;\r\n\r\n\t@Before\r\n\tpublic void setUp() {\r\n\t\tcoffeeContainer = EasyMock.createMock(CoffeeContainer.class);\r\n\t\twaterContainer = EasyMock.createMock(WaterContainer.class);\r\n\t\tcoffeeMachine = new CoffeeMachine(coffeeContainer, waterContainer);\r\n\t}\r\n\r\n\t@After\r\n\tpublic void tearDown() {\r\n\t\tcoffeeContainer = null;\r\n\t\twaterContainer = null;\r\n\t\tcoffeeMachine = null;\t\t\r\n\t}\r\n\r\n\t@Test\r\n\tpublic void testMakeCoffe() throws NotEnoughException {\r\n\t\tEasyMock.expect(coffeeContainer.getPortion(Portion.LARGE)).andReturn(true);\r\n\t\tEasyMock.replay(coffeeContainer);\r\n\r\n\t\tEasyMock.expect(waterContainer.getPortion(Portion.LARGE)).andReturn(true);\r\n\t\tEasyMock.replay(waterContainer);\r\n\r\n\t\tassertTrue(coffeeMachine.makeCoffee(Portion.LARGE));\r\n\t}\r\n\r\n\t@Test\r\n\tpublic void testNotEnoughException() throws NotEnoughException {\r\n\t\tEasyMock.expect(coffeeContainer.getPortion(Portion.LARGE)).andReturn(false);\r\n\t\tEasyMock.replay(coffeeContainer);\r\n\r\n\t\tEasyMock.expect(waterContainer.getPortion(Portion.LARGE)).andReturn(true);\r\n\t\tEasyMock.replay(waterContainer);\r\n\r\n\t\tassertFalse(coffeeMachine.makeCoffee(Portion.LARGE));\r\n\t}\r\n\r\n}<\/pre>\n<p>In the previous code snippet you see cooperation of JUnit and EasyMock. I can underline several fundamental things in EasyMock usage.<\/p>\n<ol>\n<li>If test requires interaction with some external object you should mock it.\n<pre class=\" brush:java\">coffeeContainer = EasyMock.createMock(CoffeeContainer.class);<\/pre>\n<\/li>\n<li>Set a behavior for a mock or for a concrete method which is required for the testing of object under the test.\n<pre class=\"brush:java\">EasyMock.expect(coffeeContainer.getPortion(Portion.LARGE)).andReturn(true);<\/pre>\n<\/li>\n<li>Switch a mock to a reply mode.\n<pre class=\" brush:java\">EasyMock.replay(coffeeContainer);<\/pre>\n<p>EasyMock has a lot of different methods its API not small, so I recomend to read more on the <a title=\"EasyMock API\" href=\"http:\/\/www.easymock.org\/api\/easymock\/3.1\/org\/easymock\/EasyMock.html\" target=\"_blank\">official site<\/a>.<\/li>\n<\/ol>\n<h2>JUnit test suite<\/h2>\n<p>When you have a small application, you can launch JUnit tests separately, but what if you work on a large and complex application? In this case unit tests can be aggregated in test suits by some feature. JUnit provide convenient way for this.<\/p>\n<pre class=\" brush:java\">@RunWith(Suite.class)\r\n@SuiteClasses({ AbstractContainerTest.class, CoffeeMachineTest.class })\r\npublic class AllTests {\r\n\r\n}<\/pre>\n<h2>Summary<\/h2>\n<p>Unit testing it\u2019s a very important part of software development, it has a lot of approaches, methodologies and tools. In this post I have made an overview of JUnit and EasyMock, but I omited many interesting moments and technics which I plan to cover in following tutorials. You can download <a href=\"https:\/\/www.dropbox.com\/s\/t2mxjceodnel8es\/unit_testing.rar\" target=\"_blank\">source code<\/a> of the tutorial from my DropBox.<br \/>\n&nbsp;<\/p>\n<p><b><i>Reference: <\/i><\/b><a href=\"http:\/\/fruzenshtein.com\/junit-and-easymock-cooperation\/\">JUnit and EasyMock cooperation<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/p\/jcg.html\">JCG partner<\/a> Alex Fruzenshtein at the <a href=\"http:\/\/fruzenshtein.com\/\">Fruzenshtein&#8217;s notes<\/a> blog.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Developers always need to take care about code which they produced. They should be ensured that code works properly after a new feature was implemented or some bug was fixed. That\u2019s can be achieved at least with the help of unit tests. Since this blog is dedicated to Java programming language, today I will write &hellip;<\/p>\n","protected":false},"author":374,"featured_media":107,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[593,274,273],"class_list":["post-10338","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-easymock","tag-junit","tag-testing"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>JUnit and EasyMock cooperation<\/title>\n<meta name=\"description\" content=\"Developers always need to take care about code which they produced. They should be ensured that code works properly after a new feature was implemented or\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2013\/03\/junit-and-easymock-cooperation.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JUnit and EasyMock cooperation\" \/>\n<meta property=\"og:description\" content=\"Developers always need to take care about code which they produced. They should be ensured that code works properly after a new feature was implemented or\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2013\/03\/junit-and-easymock-cooperation.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2013-03-25T17:00:12+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/easymock-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Alexey Zvolinskiy\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Alexey Zvolinskiy\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/junit-and-easymock-cooperation.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/junit-and-easymock-cooperation.html\"},\"author\":{\"name\":\"Alexey Zvolinskiy\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/ac87395bf8afb0ae3515feb6a0f36d02\"},\"headline\":\"JUnit and EasyMock cooperation\",\"datePublished\":\"2013-03-25T17:00:12+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/junit-and-easymock-cooperation.html\"},\"wordCount\":1069,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/junit-and-easymock-cooperation.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/easymock-logo.jpg\",\"keywords\":[\"EasyMock\",\"JUnit\",\"Testing\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/junit-and-easymock-cooperation.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/junit-and-easymock-cooperation.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/junit-and-easymock-cooperation.html\",\"name\":\"JUnit and EasyMock cooperation\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/junit-and-easymock-cooperation.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/junit-and-easymock-cooperation.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/easymock-logo.jpg\",\"datePublished\":\"2013-03-25T17:00:12+00:00\",\"description\":\"Developers always need to take care about code which they produced. They should be ensured that code works properly after a new feature was implemented or\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/junit-and-easymock-cooperation.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/junit-and-easymock-cooperation.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/junit-and-easymock-cooperation.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/easymock-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/easymock-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/03\\\/junit-and-easymock-cooperation.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"JUnit and EasyMock cooperation\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/ac87395bf8afb0ae3515feb6a0f36d02\",\"name\":\"Alexey Zvolinskiy\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/082c897ff3a223afa16dedb5c6638b8b7caef162b241379e9c755b70aed186f5?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/082c897ff3a223afa16dedb5c6638b8b7caef162b241379e9c755b70aed186f5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/082c897ff3a223afa16dedb5c6638b8b7caef162b241379e9c755b70aed186f5?s=96&d=mm&r=g\",\"caption\":\"Alexey Zvolinskiy\"},\"description\":\"Alexey is a test developer with solid experience in automation of web-applications using Java, TestNG and Selenium. He is so much into QA that even after work he provides training courses for junior QA engineers.\",\"sameAs\":[\"http:\\\/\\\/fruzenshtein.com\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/alexey-zvolinskiy\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JUnit and EasyMock cooperation","description":"Developers always need to take care about code which they produced. They should be ensured that code works properly after a new feature was implemented or","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2013\/03\/junit-and-easymock-cooperation.html","og_locale":"en_US","og_type":"article","og_title":"JUnit and EasyMock cooperation","og_description":"Developers always need to take care about code which they produced. They should be ensured that code works properly after a new feature was implemented or","og_url":"https:\/\/www.javacodegeeks.com\/2013\/03\/junit-and-easymock-cooperation.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-03-25T17:00:12+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/easymock-logo.jpg","type":"image\/jpeg"}],"author":"Alexey Zvolinskiy","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Alexey Zvolinskiy","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/junit-and-easymock-cooperation.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/junit-and-easymock-cooperation.html"},"author":{"name":"Alexey Zvolinskiy","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/ac87395bf8afb0ae3515feb6a0f36d02"},"headline":"JUnit and EasyMock cooperation","datePublished":"2013-03-25T17:00:12+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/junit-and-easymock-cooperation.html"},"wordCount":1069,"commentCount":0,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/junit-and-easymock-cooperation.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/easymock-logo.jpg","keywords":["EasyMock","JUnit","Testing"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2013\/03\/junit-and-easymock-cooperation.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/junit-and-easymock-cooperation.html","url":"https:\/\/www.javacodegeeks.com\/2013\/03\/junit-and-easymock-cooperation.html","name":"JUnit and EasyMock cooperation","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/junit-and-easymock-cooperation.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/junit-and-easymock-cooperation.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/easymock-logo.jpg","datePublished":"2013-03-25T17:00:12+00:00","description":"Developers always need to take care about code which they produced. They should be ensured that code works properly after a new feature was implemented or","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/junit-and-easymock-cooperation.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2013\/03\/junit-and-easymock-cooperation.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/junit-and-easymock-cooperation.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/easymock-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/easymock-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2013\/03\/junit-and-easymock-cooperation.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"JUnit and EasyMock cooperation"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/ac87395bf8afb0ae3515feb6a0f36d02","name":"Alexey Zvolinskiy","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/082c897ff3a223afa16dedb5c6638b8b7caef162b241379e9c755b70aed186f5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/082c897ff3a223afa16dedb5c6638b8b7caef162b241379e9c755b70aed186f5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/082c897ff3a223afa16dedb5c6638b8b7caef162b241379e9c755b70aed186f5?s=96&d=mm&r=g","caption":"Alexey Zvolinskiy"},"description":"Alexey is a test developer with solid experience in automation of web-applications using Java, TestNG and Selenium. He is so much into QA that even after work he provides training courses for junior QA engineers.","sameAs":["http:\/\/fruzenshtein.com\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/alexey-zvolinskiy"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/10338","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/374"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=10338"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/10338\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/107"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=10338"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=10338"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=10338"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}