{"id":44436,"date":"2017-04-06T11:00:21","date_gmt":"2017-04-06T08:00:21","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=44436"},"modified":"2019-03-20T14:00:11","modified_gmt":"2019-03-20T12:00:11","slug":"junit-testcase-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/","title":{"rendered":"JUnit Testcase Example"},"content":{"rendered":"<p>In this example, we shall show users how to use JUnit Testcase. JUnit Testcase example will follow you to the scenarios of how we can use and test our methods with the help of the JUnit Testcase.<\/p>\n<p>As a regular reader, you are already familiar with the JUnit and its usage. If you are new to it you are recommend to visit <a href=\"https:\/\/examples.javacodegeeks.com\/category\/core-java\/junit\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">JUnit Series<\/a> on Java Code Geeks.<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<br \/>\n&nbsp;<\/p>\n<p>&nbsp;<br \/>\nBefore this article, I have shown many different uses of JUnit and its many different properties. But in this example, we will show something different which we haven&#8217;t done in previous articles.<\/p>\n<h2>1. Introduction<\/h2>\n<p><a href=\"http:\/\/junit.org\/junit4\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">JUnit<\/a> provides a class known as <code>TestCase<\/code>. This class will help us to run all our test cases. In previous articles, we have used the <code>@Test<\/code> annotation on all our test cases. But, here we will not use any annotation and see how we can test the methods with the help of the <code>TestCase<\/code> class.<\/p>\n<p>We will create a class by extending the <code>TestCase<\/code> class and then proceed further for testing. Let&#8217;s start creating a project.<\/p>\n<h2>2. Technologies Used<\/h2>\n<p>Following technologies are used in this example.<\/p>\n<ul>\n<li><strong>Java 8<\/strong>: Language for example<\/li>\n<li><strong>JUnit 4.12<\/strong>: Testing Framework<\/li>\n<li><strong>Maven<\/strong>: Dependency and build tool<\/li>\n<li><strong>Eclipse<\/strong>: IDE for coding<\/li>\n<\/ul>\n<h2>3. Project Setup<\/h2>\n<div class=\"tip\"><strong>Tip<\/strong><br \/>\nYou may skip project creation and jump directly to the <a href=\"#code\"><strong>beginning of the example<\/strong><\/a> below.<\/div>\n<p>We will be using the Eclipse and <a href=\"http:\/\/maven.apache.org\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Maven<\/a> for our project. Click <strong>File -&gt; New -&gt; Maven Project&nbsp;<\/strong>On the first screen simply check the check mark corresponding to the &#8220;Create a simple project&#8221; and click on <strong>Next<\/strong> button.<\/p>\n<p><figure id=\"attachment_44438\" aria-describedby=\"caption-attachment-44438\" style=\"width: 725px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/junit-testcase-example-setup-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-44438\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/junit-testcase-example-setup-1.jpg\" alt=\"JUnit Testcase Example Setup 1\" width=\"725\" height=\"503\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/junit-testcase-example-setup-1.jpg 725w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/junit-testcase-example-setup-1-300x208.jpg 300w\" sizes=\"(max-width: 725px) 100vw, 725px\" \/><\/a><figcaption id=\"caption-attachment-44438\" class=\"wp-caption-text\">Figure 1: JUnit Testcase Example Setup 1<\/figcaption><\/figure><div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>Fill in all the details and click on <strong>Finish<\/strong> button.<\/p>\n<p><figure id=\"attachment_44439\" aria-describedby=\"caption-attachment-44439\" style=\"width: 724px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/junit-testcase-example-setup-2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-44439\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/junit-testcase-example-setup-2.jpg\" alt=\"JUnit Testcase Example Setup 2\" width=\"724\" height=\"667\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/junit-testcase-example-setup-2.jpg 724w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/junit-testcase-example-setup-2-300x276.jpg 300w\" sizes=\"(max-width: 724px) 100vw, 724px\" \/><\/a><figcaption id=\"caption-attachment-44439\" class=\"wp-caption-text\">JUnit Testcase Example Setup 2<\/figcaption><\/figure><\/p>\n<p>Now our blank project is ready.<\/p>\n<h2>4. JUnit Testcase Example<\/h2>\n<p><span id=\"code\"><\/span><br \/>\nWe will be doing 2 things here. First configure the JUnit by adding dependency in the <code>pom.xml<\/code> and secondly, creating java classes for testing.<\/p>\n<h3>4.1 xml configuration<\/h3>\n<p>Firstly, put the following code in the <code>pom.xml<\/code>.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml;wrap-lines:false\">    &lt;dependencies&gt;\n        &lt;dependency&gt;\n            &lt;groupId&gt;junit&lt;\/groupId&gt;\n            &lt;artifactId&gt;junit&lt;\/artifactId&gt;\n            &lt;version&gt;4.12&lt;\/version&gt;\n        &lt;\/dependency&gt;\n    &lt;\/dependencies&gt;\n\n    &lt;properties&gt;\n        &lt;maven.compiler.source&gt;1.8&lt;\/maven.compiler.source&gt;\n        &lt;maven.compiler.target&gt;1.8&lt;\/maven.compiler.target&gt;\n    &lt;\/properties&gt;\n<\/pre>\n<p>Here we are simply telling maven to pull dependency of <code>JUnit 4.12<\/code> and use <code>Java 8<\/code> for compile.<\/p>\n<h3>4.2 Java classes<\/h3>\n<p>Next step is to create a model class which will help in testing.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>ListTest.java<\/em><\/span><\/p>\n<pre class=\"brush:java;wrap-lines:false\">package junittestcase;\n\nimport java.util.ArrayList;\nimport java.util.List;\n\npublic class ListTest {\n\n    private List lstFruits = new ArrayList();\n\n    public void add(String fruit) {\n        lstFruits.add(fruit);\n    }\n\n    public void remove(String fruit) {\n        lstFruits.remove(fruit);\n    }\n\n    public int size() {\n        return lstFruits.size();\n    }\n    \n    public void removeAll(){\n        lstFruits.clear();\n    }\n}\n<\/pre>\n<p>Now we are ready to write our main class that will actually run our test cases. We need to follow some points so that we run our test cases:[ulp id=&#8217;ODQaBEw1BIbHApZq&#8217;]<\/p>\n<ul>\n<li>We need to extend the <code>TestCase<\/code> class of JUnit<\/li>\n<li><code>setUp()<\/code> and <code>tearDown() <\/code>methods, which are optional and runs before and after every test case.<\/li>\n<li>Every test case shouls be public and name should begin with <em><strong>test<\/strong><\/em>. They should not take any argument.<\/li>\n<li>Test case should not return any value.<\/li>\n<\/ul>\n<p><span style=\"text-decoration: underline;\"><em>MyTestCase.java<\/em><\/span><\/p>\n<pre class=\"brush:java;wrap-lines:false;highlight:[5,9,15,19,24,29]\">package junittestcase;\n\nimport junit.framework.TestCase;\n\npublic class MyTestCase extends TestCase {\n\n    protected ListTest lstTest = new ListTest();\n\n    protected void setUp() {\n        lstTest.add(\"Apple\");\n        lstTest.add(\"Orange\");\n        lstTest.add(\"Grapes\");\n    }\n\n    public void testSize() {\n        assertEquals(\"Checking size of List\", 3, lstTest.size());\n    }\n\n    public void testAdd() {\n        lstTest.add(\"Banana\");\n        assertEquals(\"Adding 1 more fruit to list\", 4, lstTest.size());\n    }\n\n    public void testRemove() {\n        lstTest.remove(\"Orange\");\n        assertEquals(\"Removing 1 fruit from list\", 2, lstTest.size());\n    }\n\n    protected void tearDown() {\n        lstTest.removeAll();\n    }\n}\n<\/pre>\n<p>Let&#8217;s analyze all the details line by line of this class.<br \/>\nAt line no 5, we have extended the <code>TestCase<\/code> class.<br \/>\nLine no 9, specifies a <code>setUp()<\/code> method that will run before any test method.<br \/>\nLine 15,19,24 are our test cases.<br \/>\nLine no 29 specifies the <code>tearDown()<\/code> method that will be called after each test case.<\/p>\n<p>It is to be noted that, <code>setUp()<\/code> and <code>tearDown()<\/code> are not mandatory at all. We have used here only to illustrate the usage of them.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Output<\/em><\/span><\/p>\n<p><figure id=\"attachment_44441\" aria-describedby=\"caption-attachment-44441\" style=\"width: 532px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/junit-testcase-example-output.jpg\"><img decoding=\"async\" class=\"size-full wp-image-44441\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/junit-testcase-example-output.jpg\" alt=\"JUnit Testcase Example Output\" width=\"532\" height=\"240\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/junit-testcase-example-output.jpg 532w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/junit-testcase-example-output-300x135.jpg 300w\" sizes=\"(max-width: 532px) 100vw, 532px\" \/><\/a><figcaption id=\"caption-attachment-44441\" class=\"wp-caption-text\">Figure 3: JUnit Testcase Example Output<\/figcaption><\/figure><\/p>\n<h2>5. Conclusion<\/h2>\n<p>We have learned a way to test our test cases with the help of the <code>TestCase<\/code> class of JUnit. Now a days we are using annotations instead of the <code>TestCase<\/code> class. But through JUnit Testcase example we have learned a new way to test.<\/p>\n<h2>6. Download the Eclipse Project<\/h2>\n<p>This is a JUnit Testcase Example.<\/p>\n<div class=\"download\"><strong>Download<\/strong><br \/>\nYou can download the full source code of this example here: <a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/04\/junittestcase.zip\"><strong>JUnitTestcaseExample<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this example, we shall show users how to use JUnit Testcase. JUnit Testcase example will follow you to the scenarios of how we can use and test our methods with the help of the JUnit Testcase. As a regular reader, you are already familiar with the JUnit and its usage. If you are new &hellip;<\/p>\n","protected":false},"author":112,"featured_media":6678,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[25],"tags":[],"class_list":["post-44436","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-junit"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JUnit Testcase Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"JUnit Testcase example will follow you to the scenarios of how we can use and test our methods with the help of the JUnit Testcase.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JUnit Testcase Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"JUnit Testcase example will follow you to the scenarios of how we can use and test our methods with the help of the JUnit Testcase.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2017-04-06T08:00:21+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-03-20T12:00:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-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=\"Vinod Kumar Kashyap\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vinodkashyap\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Vinod Kumar Kashyap\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/\"},\"author\":{\"name\":\"Vinod Kumar Kashyap\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/1d6281e8235e49b5b8614621c2445d2c\"},\"headline\":\"JUnit Testcase Example\",\"datePublished\":\"2017-04-06T08:00:21+00:00\",\"dateModified\":\"2019-03-20T12:00:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/\"},\"wordCount\":609,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg\",\"articleSection\":[\"junit\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/\",\"name\":\"JUnit Testcase Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg\",\"datePublished\":\"2017-04-06T08:00:21+00:00\",\"dateModified\":\"2019-03-20T12:00:11+00:00\",\"description\":\"JUnit Testcase example will follow you to the scenarios of how we can use and test our methods with the help of the JUnit Testcase.\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"junit\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/junit\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"JUnit Testcase Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/1d6281e8235e49b5b8614621c2445d2c\",\"name\":\"Vinod Kumar Kashyap\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/a11634ec460c849e8631b740af1b75cb68c9c58d5c2339c21bcd95f55b9af4f5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/a11634ec460c849e8631b740af1b75cb68c9c58d5c2339c21bcd95f55b9af4f5?s=96&d=mm&r=g\",\"caption\":\"Vinod Kumar Kashyap\"},\"description\":\"Vinod is Sun Certified and love to work in Java and related technologies. Having more than 13 years of experience, he had developed software's including technologies like Java, Hibernate, Struts, Spring, HTML 5, jQuery, CSS, Web Services, MongoDB, AngularJS, AWS. He is also a JUG Leader of Chandigarh Java User Group.\",\"sameAs\":[\"http:\/\/www.vinodkashyap.com\/\",\"https:\/\/www.instagram.com\/vinodkashyap\/\",\"https:\/\/in.linkedin.com\/in\/vinodkashyap\",\"https:\/\/in.pinterest.com\/vinodkashyap\/\",\"https:\/\/x.com\/vinodkashyap\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/vinod-kashyap\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"JUnit Testcase Example - Java Code Geeks","description":"JUnit Testcase example will follow you to the scenarios of how we can use and test our methods with the help of the JUnit Testcase.","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:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/","og_locale":"en_US","og_type":"article","og_title":"JUnit Testcase Example - Java Code Geeks","og_description":"JUnit Testcase example will follow you to the scenarios of how we can use and test our methods with the help of the JUnit Testcase.","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2017-04-06T08:00:21+00:00","article_modified_time":"2019-03-20T12:00:11+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg","type":"image\/jpeg"}],"author":"Vinod Kumar Kashyap","twitter_card":"summary_large_image","twitter_creator":"@vinodkashyap","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Vinod Kumar Kashyap","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/"},"author":{"name":"Vinod Kumar Kashyap","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/1d6281e8235e49b5b8614621c2445d2c"},"headline":"JUnit Testcase Example","datePublished":"2017-04-06T08:00:21+00:00","dateModified":"2019-03-20T12:00:11+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/"},"wordCount":609,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg","articleSection":["junit"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/","name":"JUnit Testcase Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg","datePublished":"2017-04-06T08:00:21+00:00","dateModified":"2019-03-20T12:00:11+00:00","description":"JUnit Testcase example will follow you to the scenarios of how we can use and test our methods with the help of the JUnit Testcase.","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-testcase-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/"},{"@type":"ListItem","position":4,"name":"junit","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/junit\/"},{"@type":"ListItem","position":5,"name":"JUnit Testcase Example"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/1d6281e8235e49b5b8614621c2445d2c","name":"Vinod Kumar Kashyap","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/a11634ec460c849e8631b740af1b75cb68c9c58d5c2339c21bcd95f55b9af4f5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/a11634ec460c849e8631b740af1b75cb68c9c58d5c2339c21bcd95f55b9af4f5?s=96&d=mm&r=g","caption":"Vinod Kumar Kashyap"},"description":"Vinod is Sun Certified and love to work in Java and related technologies. Having more than 13 years of experience, he had developed software's including technologies like Java, Hibernate, Struts, Spring, HTML 5, jQuery, CSS, Web Services, MongoDB, AngularJS, AWS. He is also a JUG Leader of Chandigarh Java User Group.","sameAs":["http:\/\/www.vinodkashyap.com\/","https:\/\/www.instagram.com\/vinodkashyap\/","https:\/\/in.linkedin.com\/in\/vinodkashyap","https:\/\/in.pinterest.com\/vinodkashyap\/","https:\/\/x.com\/vinodkashyap"],"url":"https:\/\/examples.javacodegeeks.com\/author\/vinod-kashyap\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/44436","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/112"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=44436"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/44436\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/6678"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=44436"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=44436"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=44436"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}