{"id":43553,"date":"2017-02-14T11:00:07","date_gmt":"2017-02-14T09:00:07","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=43553"},"modified":"2019-03-21T11:08:43","modified_gmt":"2019-03-21T09:08:43","slug":"junit-keyboard-input-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/","title":{"rendered":"JUnit Keyboard Input Example"},"content":{"rendered":"<p>In this post we shall show users the usage of JUnit keyboard input working. This example is very useful in case users want to enter data from keyboard for testing of their methods. Do not worry, we will the same in the post.<\/p>\n<p>Users are advised to see the <a href=\"http:\/\/examples.javacodegeeks.com\/core-java\/junit\/junit-hello-world-example\/\" target=\"_blank\" rel=\"noopener noreferrer\">JUnit Hello World<\/a> example where they can see the basic usage of JUnit. In addition, if users want to run their test cases in the order of their choice, they are recommended to visit <a href=\"http:\/\/examples.javacodegeeks.com\/core-java\/junit\/junit-fixmethodorder-example\/\" target=\"_blank\" rel=\"noopener noreferrer\">JUnit FixMethodOrder<\/a> example.<\/p>\n<p>First of all, let&#8217;s start with the small introduction of JUnit.<\/p>\n<h2>1. JUnit Introduction<\/h2>\n<p><a href=\"http:\/\/junit.org\" target=\"_blank\" rel=\"noopener noreferrer\">JUnit<\/a> is a testing framework for Java programmers. This is the testing framework where users can unit test their methods for working. Almost all Java programmers used this framework for basic testing. Basic example of the JUnit can be seen in <a href=\"http:\/\/examples.javacodegeeks.com\/core-java\/junit\/junit-hello-world-example\/\" target=\"_blank\" rel=\"noopener noreferrer\">JUnit Hello World<\/a> example.\n<\/p>\n<h2>2. Tools Required<\/h2>\n<p>Users have to have a basic understanding of the Java. These are the tools that are used in this example.<\/p>\n<ul>\n<li>Eclipse (users can use any tool of their choice. We are using STS, which is built on the top of the Eclipse)<\/li>\n<li>Java<\/li>\n<li>Maven (optional, users can also use this example without Maven, but we recommend to use it)<\/li>\n<li>JUnit 4.12 (this is the latest version we are using for this example)<\/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>In this post we are using the <a href=\"http:\/\/maven.apache.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">Maven<\/a> for initial setup of our application. Let&#8217;s start with the creating of the Maven project. Open eclipse, <code>File -&gt; New -&gt; Maven Project<\/code><br \/>\nOn the following screen, fill in the details as shown and click on Next button.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p><figure id=\"attachment_43566\" aria-describedby=\"caption-attachment-43566\" style=\"width: 725px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/junit-keyboard-input-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-43566\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/junit-keyboard-input-1.jpg\" alt=\"JUnit Keyboard Input Project Setup Screen 1\" width=\"725\" height=\"503\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/junit-keyboard-input-1.jpg 725w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/junit-keyboard-input-1-300x208.jpg 300w\" sizes=\"(max-width: 725px) 100vw, 725px\" \/><\/a><figcaption id=\"caption-attachment-43566\" class=\"wp-caption-text\">Figure 1: Project Setup Screen 1<\/figcaption><\/figure><\/p>\n<p>Clicking on Next button users will be taken to the below screen. Fill in the details as shown and click on finish.<\/p>\n<p><figure id=\"attachment_43567\" aria-describedby=\"caption-attachment-43567\" style=\"width: 718px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/junit-keyboard-input-2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-43567\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/junit-keyboard-input-2.jpg\" alt=\"JUnit Keyboard Input Project Setup Screen 2\" width=\"718\" height=\"665\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/junit-keyboard-input-2.jpg 718w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/junit-keyboard-input-2-300x278.jpg 300w\" sizes=\"(max-width: 718px) 100vw, 718px\" \/><\/a><figcaption id=\"caption-attachment-43567\" class=\"wp-caption-text\">Figure 2: Project Setup Screen 2<\/figcaption><\/figure><\/p>\n<p><span id=\"code\"><\/span><br \/>\nNow we are ready to start writing code for our application.<\/p>\n<h2>4. JUnit Keyboard Input<\/h2>\n<p>Open <code>pom.xml<\/code> and add the following lines to it. This is the main file which is used by the Maven to download dependencies on users local machine.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml\">&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<\/pre>\n<p>Create a class with the following code. This class will test the parameter passed for leap year. If the passed parameter is Leap year, it will return <code>true<\/code> otherwise it will return <code>false<\/code>.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>LeapYear.java<\/em><\/span><\/p>\n<pre class=\"brush:java\">package junitkeyboardinput;\n\npublic class LeapYear {\n\n\tpublic boolean isLeapYear(int year) {\n\t\treturn ((year % 400 == 0) || ((year % 4 == 0) &amp;&amp; (year % 100 != 0)));\n\t}\n}\n<\/pre>\n<p>Finally, we create a <code>LeapYearTest<\/code> class which is a JUnit keyboard input test class, that test our <code>isLeapYear()<\/code> method. We are using, <a href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/util\/Scanner.html\" target=\"_blank\" rel=\"noopener noreferrer\">Scanner<\/a> class of Java.[ulp id=&#8217;ODQaBEw1BIbHApZq&#8217;]<\/p>\n<p><span id=\"leapyear\"><\/span><br \/>\n<span style=\"text-decoration: underline;\"><em>LeapYearTest.java<\/em><\/span><\/p>\n<pre class=\"brush:java wrap-lines:false highlight:[22,24,26]\">package junitkeyboardinput;\n\nimport static org.junit.Assert.assertTrue;\n\nimport java.io.IOException;\nimport java.util.Scanner;\n\nimport org.junit.Test;\n\npublic class LeapYearTest {\n\n\t@Test\n\tpublic void isLeapYearTest() throws IOException {\n\t\tLeapYear check = new LeapYear();\n\t\tassertTrue(\"Leap Year\", check.isLeapYear(2015));\n\t}\n\n\t@Test\n\tpublic void isLeapYearKeboardTest() throws IOException {\n\t\tLeapYear leapYear = new LeapYear();\n\n\t\tScanner sc = new Scanner(System.in);\n\t\tSystem.out.print(\"Enter year(yyyy):\");\n\t\tint year = sc.nextInt();\n\t\tassertTrue(\"Leap Year\", leapYear.isLeapYear(year));\n\t\tsc.close();\n\t}\n}\n<\/pre>\n<p>Let&#8217;s see what is happening in this class.<br \/>\n<strong>Line no 22<\/strong>: We are creating object of <a href=\"http:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/util\/Scanner.html\" target=\"_blank\" rel=\"noopener noreferrer\">Scanner<\/a> class.<br \/>\n<strong>Line no 24<\/strong>: We are taking the input as <a href=\"https:\/\/docs.oracle.com\/javase\/7\/docs\/api\/java\/lang\/Integer.html\" target=\"_blank\" rel=\"noopener noreferrer\">Integer<\/a><br \/>\n<strong>Line no 26<\/strong>: closing the Scanner.<\/p>\n<p>In the console window, users will be prompted for entering year. Enter year and depend upon the input, test case will fail or pass.<\/p>\n<pre class=\"brush:bash\">Enter year(yyyy): \n<\/pre>\n<p>If user passes, 2016 as the year, result will be shown in JUnit window.<\/p>\n<pre class=\"brush:bash\">Enter year(yyyy): 2016\n<\/pre>\n<p><figure id=\"attachment_43570\" aria-describedby=\"caption-attachment-43570\" style=\"width: 742px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/junit-keyboard-input-3.jpg\"><img decoding=\"async\" class=\"size-full wp-image-43570\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/junit-keyboard-input-3.jpg\" alt=\"JUnit Result Window\" width=\"742\" height=\"335\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/junit-keyboard-input-3.jpg 742w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/02\/junit-keyboard-input-3-300x135.jpg 300w\" sizes=\"(max-width: 742px) 100vw, 742px\" \/><\/a><figcaption id=\"caption-attachment-43570\" class=\"wp-caption-text\">Figure 3: JUnit Result Window<\/figcaption><\/figure><\/p>\n<h2>5. Examine the output<\/h2>\n<p>Users can see that there are 2 test cases, out of which one is passed and other is failed. Let&#8217;s examine the output.<br \/>\n1. One of the test case is failed i.e. <code>isLeapYearTest()<\/code> , as the result of the parameter passed which is not a leap year.(See <a href=\"#leapyear\">LeapYearTest.java<\/a>, line no 15)<br \/>\n2. Other test is passed i.e. <code>isLeapYearKeboardTest()<\/code>, as we have passed the leap year.<\/p>\n<p>We advised users to experiment with the example to see the real output.<\/p>\n<h2>6. Conclusion<\/h2>\n<p>In conclusion, this is an example of JUnit Keyboard input, where we&nbsp;have learnt how they can use the keyboard to test their methods in JUnit.<\/p>\n<h2>7. Download the Eclipse Project<\/h2>\n<p>This was an example of JUnit Keyboard Input.<\/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\/junitkeyboardinput.zip\"><strong>JUnitKeyboardInput.zip<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this post we shall show users the usage of JUnit keyboard input working. This example is very useful in case users want to enter data from keyboard for testing of their methods. Do not worry, we will the same in the post. Users are advised to see the JUnit Hello World example where they &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":[189],"class_list":["post-43553","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-junit","tag-core-java-2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JUnit Keyboard Input Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In this post we shall show the usage of JUnit keyboard input. This example is very useful in case user wants to enter data from keyboard for testing\" \/>\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-keyboard-input-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JUnit Keyboard Input Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In this post we shall show the usage of JUnit keyboard input. This example is very useful in case user wants to enter data from keyboard for testing\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-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-14T09:00:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-03-21T09:08:43+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-keyboard-input-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/\"},\"author\":{\"name\":\"Vinod Kumar Kashyap\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/1d6281e8235e49b5b8614621c2445d2c\"},\"headline\":\"JUnit Keyboard Input Example\",\"datePublished\":\"2017-02-14T09:00:07+00:00\",\"dateModified\":\"2019-03-21T09:08:43+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/\"},\"wordCount\":643,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg\",\"keywords\":[\"core java\"],\"articleSection\":[\"junit\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/\",\"name\":\"JUnit Keyboard Input Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg\",\"datePublished\":\"2017-02-14T09:00:07+00:00\",\"dateModified\":\"2019-03-21T09:08:43+00:00\",\"description\":\"In this post we shall show the usage of JUnit keyboard input. This example is very useful in case user wants to enter data from keyboard for testing\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-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-keyboard-input-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 Keyboard Input 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 Keyboard Input Example - Java Code Geeks","description":"In this post we shall show the usage of JUnit keyboard input. This example is very useful in case user wants to enter data from keyboard for testing","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-keyboard-input-example\/","og_locale":"en_US","og_type":"article","og_title":"JUnit Keyboard Input Example - Java Code Geeks","og_description":"In this post we shall show the usage of JUnit keyboard input. This example is very useful in case user wants to enter data from keyboard for testing","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2017-02-14T09:00:07+00:00","article_modified_time":"2019-03-21T09:08:43+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-keyboard-input-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/"},"author":{"name":"Vinod Kumar Kashyap","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/1d6281e8235e49b5b8614621c2445d2c"},"headline":"JUnit Keyboard Input Example","datePublished":"2017-02-14T09:00:07+00:00","dateModified":"2019-03-21T09:08:43+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/"},"wordCount":643,"commentCount":0,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg","keywords":["core java"],"articleSection":["junit"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/","name":"JUnit Keyboard Input Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg","datePublished":"2017-02-14T09:00:07+00:00","dateModified":"2019-03-21T09:08:43+00:00","description":"In this post we shall show the usage of JUnit keyboard input. This example is very useful in case user wants to enter data from keyboard for testing","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-keyboard-input-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-keyboard-input-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 Keyboard Input 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\/43553","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=43553"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/43553\/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=43553"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=43553"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=43553"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}