{"id":43467,"date":"2017-02-09T11:00:44","date_gmt":"2017-02-09T09:00:44","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=43467"},"modified":"2019-03-21T11:10:09","modified_gmt":"2019-03-21T09:10:09","slug":"junit-hello-world-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/","title":{"rendered":"JUnit Hello World Example"},"content":{"rendered":"<p>In this example we shall show you how to start with JUnit hello world. <a href=\"http:\/\/junit.org\">JUnit<\/a> is an open-source testing framework used by Java programmers. It contains various methods to include in class to make your test cases run smoothly.<\/p>\n<p>Currently latest stable version is 4.x and 5.x is coming most probably in Q1 of 2017. JUnit contains many annotations that are used while creating test cases.<\/p>\n<ul>\n<li><strong>@BeforeClass<\/strong>: It is used to write code that we want to run before all test cases.<\/li>\n<li><strong>@Before<\/strong>: It will run before every test case.<\/li>\n<li><strong>@Test<\/strong>: This is actual test case.<\/li>\n<li><strong>@After<\/strong>: It will run after every test case.<\/li>\n<li><strong>@AfterClass<\/strong>: It is used to write code that we want to run after all test cases.<\/li>\n<\/ul>\n<p>For the sake of simplicity of the example we are using the <a href=\"https:\/\/maven.apache.org\/\">Maven<\/a> so that you don&#8217;t need to include the jar yourself. Maven is dependency management tool for Java. The jar and its dependencies would be automatically pulled by Maven.<\/p>\n<p><strong>Tools\/technologies needed:<\/strong><br \/>\nEclipse<br \/>\nMaven<br \/>\nJava<br \/>\nJUnit 4.12 (pulled by Maven automatically)<\/p>\n<p>With this example we will try to show the basic usage of the JUnit. Let&#8217;s start with the creation of project in Eclipse.\n<\/p>\n<h2>1. Setup JUnit Hello World Project<\/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>First you need to Select <em>File -&gt; New -&gt; Maven Project<\/em><\/p>\n<p>You will see the below screen. Select the top most checkbox as we need simple maven project.<\/p>\n<p><figure id=\"attachment_43469\" aria-describedby=\"caption-attachment-43469\" style=\"width: 691px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/screen1.jpg\"><img decoding=\"async\" class=\"wp-image-43469 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/screen1.jpg\" alt=\"First page for JUnit Hello World project\" width=\"691\" height=\"597\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/screen1.jpg 691w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/screen1-300x259.jpg 300w\" sizes=\"(max-width: 691px) 100vw, 691px\" \/><\/a><figcaption id=\"caption-attachment-43469\" class=\"wp-caption-text\">First page for maven project<\/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>Click on Next button which will take you to second screen. Fill the required details as described in below:<\/p>\n<p><figure id=\"attachment_43472\" aria-describedby=\"caption-attachment-43472\" style=\"width: 702px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/screen2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-43472\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/screen2.jpg\" alt=\"\" width=\"702\" height=\"609\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/screen2.jpg 702w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/screen2-300x260.jpg 300w\" sizes=\"(max-width: 702px) 100vw, 702px\" \/><\/a><figcaption id=\"caption-attachment-43472\" class=\"wp-caption-text\">Maven project configurations<\/figcaption><\/figure><\/p>\n<p>Click on finish. Now you are ready for your project. Open <code>pom.xml<\/code> and copy dependencies to it.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml\">&lt;dependencies&gt;\n&nbsp;&lt;dependency&gt;\n&nbsp;&nbsp;&lt;groupId&gt;junit&lt;\/groupId&gt;\n&nbsp;&nbsp;&lt;artifactId&gt;junit&lt;\/artifactId&gt;\n&nbsp;&nbsp;&lt;version&gt;4.12&lt;\/version&gt;\n&nbsp;&lt;\/dependency&gt;\n&lt;\/dependencies&gt;<\/pre>\n<h2>2. Java Classes<\/h2>\n<p>Let&#8217;s create class which contains one method.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>JUnitHelloWorld.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package junit;\n\npublic class JUnitHelloWorld {\n\n\tpublic boolean isGreater(int num1, int num2){\n\t\treturn num1 &gt; num2;\n\t}\n}\n<\/pre>\n<p>In this class we have a method named <code>isGreater()<\/code> which tells us that if first number is greater than second number or not. It will return <code>true <\/code>or <code>false <\/code>depending on the parameters passed.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>JUnitHelloWorldTest.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package junit;\n\nimport static org.junit.Assert.assertTrue;\n\nimport org.junit.After;\nimport org.junit.AfterClass;\nimport org.junit.Before;\nimport org.junit.BeforeClass;\nimport org.junit.Test;\n\npublic class JUnitHelloWorldTest {\n\n\t@BeforeClass\n\tpublic static void beforeClass() {\n\t\tSystem.out.println(\"Before Class\");\n\t}\n\n\t@Before\n\tpublic void before() {\n\t\tSystem.out.println(\"Before Test Case\");\n\t}\n\n\t@Test\n\tpublic void isGreaterTest() {\n\t\tSystem.out.println(\"Test\");\n\t\tJUnitHelloWorld helloWorld = new JUnitHelloWorld();\n\t\tassertTrue(\"Num 1 is greater than Num 2\", helloWorld.isGreater(4, 3));\n\t}\n\n\t@After\n\tpublic void after() {\n\t\tSystem.out.println(\"After Test Case\");\n\t}\n\n\t@AfterClass\n\tpublic static void afterClass() {\n\t\tSystem.out.println(\"After Class\");\n\t}\n}\n<\/pre>\n<p>In this class we can see there are five methods. Most important is the <code>@Test<\/code> method, which is our main test case. Other methods are optional and may or may not be used.[ulp id=&#8217;ODQaBEw1BIbHApZq&#8217;]<\/p>\n<h2>3. Run JUnit Project<\/h2>\n<p>Right click on <code>JUnitHelloWorldTest<\/code> and <em>Run As -&gt; JUnit Test.&nbsp;<\/em>We will see the following output:<\/p>\n<p><figure id=\"attachment_43476\" aria-describedby=\"caption-attachment-43476\" style=\"width: 599px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/screen3.jpg\" name=\"junit-passed\"><img decoding=\"async\" class=\"size-full wp-image-43476\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/screen3.jpg\" alt=\"\" width=\"599\" height=\"287\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/screen3.jpg 599w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/screen3-300x144.jpg 300w\" sizes=\"(max-width: 599px) 100vw, 599px\" \/><\/a><figcaption id=\"caption-attachment-43476\" class=\"wp-caption-text\">JUnit Test Case Passed<\/figcaption><\/figure><\/p>\n<p>And also &nbsp;in the output window here&#8217;s what we should see<\/p>\n<p><figure id=\"attachment_43478\" aria-describedby=\"caption-attachment-43478\" style=\"width: 470px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/screen5.jpg\"><img decoding=\"async\" class=\"size-full wp-image-43478\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/screen5.jpg\" alt=\"\" width=\"470\" height=\"202\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/screen5.jpg 470w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/screen5-300x129.jpg 300w\" sizes=\"(max-width: 470px) 100vw, 470px\" \/><\/a><figcaption id=\"caption-attachment-43478\" class=\"wp-caption-text\">Output of JUnit<\/figcaption><\/figure><\/p>\n<p>The result shown in image <a href=\"#junit-passed\">JUnit Test Case Passed<\/a> is due to the test case passed. We can see the <code>line number 27<\/code> from <code>JUnitHelloWorldTest<\/code> class that 4 is greater than 3.<\/p>\n<pre class=\"brush:java\">&nbsp;assertTrue(\"Num 1 is greater than Num 2\", helloWorld.isGreater(4, 3));\n<\/pre>\n<p>We can also notice&nbsp;the output in console which shows us the method calls. We can see how all annotations work and how the priority of methods is called.<\/p>\n<p>Now change the parameters to 2 and 3.<\/p>\n<pre class=\"brush:java\">&nbsp;assertTrue(\"Num 1 is greater than Num 2\", helloWorld.isGreater(2, 3));\n<\/pre>\n<p>When you run the above code it will generate the below error<\/p>\n<p><figure id=\"attachment_43479\" aria-describedby=\"caption-attachment-43479\" style=\"width: 724px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/screen6.jpg\"><img decoding=\"async\" class=\"size-full wp-image-43479\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/screen6.jpg\" alt=\"\" width=\"724\" height=\"304\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/screen6.jpg 724w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/screen6-300x126.jpg 300w\" sizes=\"(max-width: 724px) 100vw, 724px\" \/><\/a><figcaption id=\"caption-attachment-43479\" class=\"wp-caption-text\">JUnit Test Case Failed<\/figcaption><\/figure><\/p>\n<p>From above it shows that our test case fails because we are expecting the result to evaluate to <code>true<\/code> but we are getting <code>false<\/code><\/p>\n<h2>4. Download the Eclipse Project<\/h2>\n<p>This was an example of JUnit Hello World.<\/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\/02\/JUnitHelloWorld.zip\"><strong>JUnitHelloWorld<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this example we shall show you how to start with JUnit hello world. JUnit is an open-source testing framework used by Java programmers. It contains various methods to include in class to make your test cases run smoothly. Currently latest stable version is 4.x and 5.x is coming most probably in Q1 of 2017. &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":[477,1156,478],"class_list":["post-43467","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-junit","tag-apache-maven","tag-eclipse","tag-java"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JUnit Hello World Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"JUnit hello world example showing how to start with basic usage of JUnit . JUnit is open-source testing framework used by Java programmers.\" \/>\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-hello-world-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JUnit Hello World Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"JUnit hello world example showing how to start with basic usage of JUnit . JUnit is open-source testing framework used by Java programmers.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-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-02-09T09:00:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-03-21T09:10:09+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-hello-world-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/\"},\"author\":{\"name\":\"Vinod Kumar Kashyap\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/1d6281e8235e49b5b8614621c2445d2c\"},\"headline\":\"JUnit Hello World Example\",\"datePublished\":\"2017-02-09T09:00:44+00:00\",\"dateModified\":\"2019-03-21T09:10:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/\"},\"wordCount\":577,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg\",\"keywords\":[\"Apache Maven\",\"Eclipse\",\"Java\"],\"articleSection\":[\"junit\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/\",\"name\":\"JUnit Hello World Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg\",\"datePublished\":\"2017-02-09T09:00:44+00:00\",\"dateModified\":\"2019-03-21T09:10:09+00:00\",\"description\":\"JUnit hello world example showing how to start with basic usage of JUnit . JUnit is open-source testing framework used by Java programmers.\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-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-hello-world-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 Hello World 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 Hello World Example - Java Code Geeks","description":"JUnit hello world example showing how to start with basic usage of JUnit . JUnit is open-source testing framework used by Java programmers.","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-hello-world-example\/","og_locale":"en_US","og_type":"article","og_title":"JUnit Hello World Example - Java Code Geeks","og_description":"JUnit hello world example showing how to start with basic usage of JUnit . JUnit is open-source testing framework used by Java programmers.","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2017-02-09T09:00:44+00:00","article_modified_time":"2019-03-21T09:10:09+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-hello-world-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/"},"author":{"name":"Vinod Kumar Kashyap","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/1d6281e8235e49b5b8614621c2445d2c"},"headline":"JUnit Hello World Example","datePublished":"2017-02-09T09:00:44+00:00","dateModified":"2019-03-21T09:10:09+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/"},"wordCount":577,"commentCount":1,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg","keywords":["Apache Maven","Eclipse","Java"],"articleSection":["junit"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/","name":"JUnit Hello World Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg","datePublished":"2017-02-09T09:00:44+00:00","dateModified":"2019-03-21T09:10:09+00:00","description":"JUnit hello world example showing how to start with basic usage of JUnit . JUnit is open-source testing framework used by Java programmers.","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-hello-world-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-hello-world-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 Hello World 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\/43467","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=43467"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/43467\/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=43467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=43467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=43467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}