{"id":44099,"date":"2017-03-15T11:00:22","date_gmt":"2017-03-15T09:00:22","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=44099"},"modified":"2019-03-21T11:04:27","modified_gmt":"2019-03-21T09:04:27","slug":"junit-cucumber-example","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/","title":{"rendered":"JUnit Cucumber Example"},"content":{"rendered":"<p>In this example we shall show users the usage of Cucumber with JUnit. JUnit Cucumber example will follow a brief introduction about the relation they share and how we can use both with each other. This is a very basic example and users are recommended to test their own scenarios after reading this example.<\/p>\n<p>After going through example you will be familiar with the uses of Cucumber. We shall show you the basic steps for creating and building an small example which which test your cases with JUnit and Cucumber.<\/p>\n<p>If you are regular reader of my blogs you are already familiar with the JUnit. If not please go through some <a href=\"https:\/\/examples.javacodegeeks.com\/author\/vinod-kashyap\/\" target=\"_blank\" rel=\"noopener noreferrer\">JUnit examples<\/a>.<br \/>\n&nbsp;<br \/>\n&nbsp;\n<\/p>\n<h2>1. Introduction<\/h2>\n<p><a href=\"https:\/\/cucumber.io\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Cucumber<\/a> is a testing framework which supports Behaviour Driven Development (BDD). It lets us define application behaviour in plain meaningful English text using a simple grammar defined by a language called <a href=\"https:\/\/github.com\/cucumber\/cucumber\/wiki\/Gherkin\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Gherkin<\/a>. Cucumber itself is written inRuby, but it can be used to test code written in Ruby or other languages including but not limited to Java, C# and Python.<\/p>\n<p>Cucumber is providing a way for non-technical person to define test cases for a product, and on the other hand, our expectation is for smooth and timely execution of such test cases.<\/p>\n<p><a href=\"https:\/\/github.com\/cucumber\/cucumber\/wiki\/Gherkin\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Gherkin<\/a> is the language that Cucumber understands. It is a Business Readable, Domain Specific Language that lets you describe software\u2019s behaviour without detailing how that behaviour is implemented. See below how we can do this.<\/p>\n<ul>\n<li><strong><em>Given<\/em><\/strong>: The purpose of givens is to put the system in a known state before the user (or external system) starts interacting with the system (in the When steps).<\/li>\n<li><strong><em>When<\/em><\/strong>: The purpose of When steps is to describe the key action the user performs (or, using Robert C. Martin\u2019s metaphor, the state transition).<\/li>\n<li><strong><em>Then<\/em><\/strong>: The purpose of Then steps is to observe outcomes. The observations should be related to the business value\/benefit in your feature description.<\/li>\n<\/ul>\n<p>Here, we have mentioned 3 statements which are self defined.<\/p>\n<h2>2. Technologies Used<\/h2>\n<p>Some of the technologies used in this example are:<\/p>\n<ul>\n<li><strong>Java<\/strong>: language for this example<\/li>\n<li><strong>Eclipse<\/strong>: IDE for code<\/li>\n<li><strong>JUnit 4.12<\/strong>: testing framework<\/li>\n<li><strong>Cucumber<\/strong>: testing framework<\/li>\n<li><strong>Maven<\/strong>: dependency management tool<\/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>Open Eclipse. Click on <code>File -&gt; New -&gt; Maven Project&nbsp;<\/code>You will see the following screen. Fill in the details as shown.<\/p>\n<p><figure id=\"attachment_44104\" aria-describedby=\"caption-attachment-44104\" style=\"width: 725px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-cucumber-example-setup-1.jpg\"><img decoding=\"async\" class=\"size-full wp-image-44104\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-cucumber-example-setup-1.jpg\" alt=\"JUnit Cucumber Example Setup 1\" width=\"725\" height=\"503\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-cucumber-example-setup-1.jpg 725w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-cucumber-example-setup-1-300x208.jpg 300w\" sizes=\"(max-width: 725px) 100vw, 725px\" \/><\/a><figcaption id=\"caption-attachment-44104\" class=\"wp-caption-text\">Figure 1: JUnit Cucumber Example Setup 1<\/figcaption><\/figure><\/p>\n<p>On next screen, fill all the necessary details.<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_44105\" aria-describedby=\"caption-attachment-44105\" style=\"width: 722px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-cucumber-example-setup-2.jpg\"><img decoding=\"async\" class=\"size-full wp-image-44105\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-cucumber-example-setup-2.jpg\" alt=\"JUnit Cucumber Example Setup 2\" width=\"722\" height=\"666\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-cucumber-example-setup-2.jpg 722w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-cucumber-example-setup-2-300x277.jpg 300w\" sizes=\"(max-width: 722px) 100vw, 722px\" \/><\/a><figcaption id=\"caption-attachment-44105\" class=\"wp-caption-text\">Figure 2: JUnit Cucumber Example Setup 2<\/figcaption><\/figure><\/p>\n<p>Clicking on Finish will create a blank Maven project. Now we will start coding our example.<\/p>\n<h2>4. JUnit Cucumber Example<\/h2>\n<p>First of all, paste the below lines in your <code>pom.xml<\/code> of your project.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>pom.xml<\/em><\/span><\/p>\n<pre class=\"brush:xml;highlight:[5,11,18,25,26];wrap-lines:false\">&nbsp;&lt;dependencies&gt;\n\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;dependency&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;groupId&gt;info.cukes&lt;\/groupId&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;artifactId&gt;cucumber-junit&lt;\/artifactId&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;version&gt;1.2.5&lt;\/version&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;\/dependency&gt;\n\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;dependency&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;groupId&gt;junit&lt;\/groupId&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;artifactId&gt;junit&lt;\/artifactId&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;version&gt;4.12&lt;\/version&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;scope&gt;test&lt;\/scope&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;\/dependency&gt;\n\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;dependency&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;groupId&gt;info.cukes&lt;\/groupId&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;artifactId&gt;cucumber-java&lt;\/artifactId&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;version&gt;1.2.5&lt;\/version&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;scope&gt;test&lt;\/scope&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;\/dependency&gt;\n\n&nbsp;&nbsp; &nbsp;&lt;\/dependencies&gt;\n&nbsp;&nbsp; &nbsp;&lt;properties&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;maven.compiler.source&gt;1.8&lt;\/maven.compiler.source&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;maven.compiler.target&gt;1.8&lt;\/maven.compiler.target&gt;\n&nbsp;&nbsp; &nbsp;&lt;\/properties&gt;<\/pre>\n<p>Here we are asking Maven to fetch all jars related to the example. We have defined 3 jars and if there are any dependencies of these jars then they will be automatically pulled by Maven.<br \/>\nFirst at line no 5, is <code>cucumber-junit<\/code> jar, which is used with JUnit to test our example.<br \/>\nSecond at line no 11, is <code>junit<\/code> jar, which is our main jar for testing.<br \/>\nThird at line no 18, is <code>cucumber-java<\/code> jar, that is used by our application and helps cucumber to recognize our Java syntax.<br \/>\nIn line no 25,26 we have defined that maven should use 1.8 version of Java.<\/p>\n<h3>4.1 Model Class<\/h3>\n<p>Let&#8217;s start with a small model class. It is a simple class with 3 variables assigned to it and all will be used for testing. We will see the usage further in example.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>User.java<\/em><\/span><\/p>\n<pre class=\"brush:java;wrap-lines:false\">package junitcucumber;\n\npublic class User {\n\n\tprivate String name;\n\tprivate String certification;\n\tprivate int marks;\n\n\tpublic String getName() {\n\t\treturn name;\n\t}\n\n\tpublic void setName(String name) {\n\t\tthis.name = name;\n\t}\n\n\tpublic String getCertification() {\n\t\treturn certification;\n\t}\n\n\tpublic void setCertification(String certification) {\n\t\tthis.certification = certification;\n\t}\n\n\tpublic int getMarks() {\n\t\treturn marks;\n\t}\n\n\tpublic void setMarks(int marks) {\n\t\tthis.marks = marks;\n\t}\n\n\tpublic boolean getResult() {\n\t\tif (this.marks &lt; 60) {\n\t\t\treturn false;\n\t\t} else {\n\t\t\treturn true;\n\t\t}\n\t}\n\n}\n\n<\/pre>\n<h3>4.2 Testing Classes<\/h3>\n<p>We will create 2 classes that are used by Cucumber for testing. First is feature file. This is a simple file which defines our cases i.e. <code>Given<\/code>, <code>When<\/code> and <code>Then<\/code> scenarios.<br \/>\nThe extension for this file is <code>.feature<\/code>[ulp id=&#8217;ODQaBEw1BIbHApZq&#8217;]<\/p>\n<p><span style=\"text-decoration: underline;\"><em>user.feature<\/em><\/span><\/p>\n<pre class=\"brush:bash;wrap-lines:false\">Feature: User Certification\n    Scenario: User is Passed\n        Given that the user Vinod is given a task to clear Java certification exam\n        When Vinod got 60 marks in exam\n        Then Vinod is known as Java certified\n<\/pre>\n<p>In this file we have defined some of the test scenarios. Let&#8217;s examine them.<br \/>\nLine no 1 specifies the name of our feature i.e. a name that can be used to identified the feature.<br \/>\nLine no 2 defines the Scenario. Here we are writing the name of the scenario that we want to test. In our case we are testing that User is certified.<br \/>\nNext 3 lines are self defined and explained above.<\/p>\n<p>After writing the features that we want to test, we need to create the steps file that tell cucumber what exactly to be tested.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>UserSteps.java<\/em><\/span><\/p>\n<pre class=\"brush:java;wrap-lines:false\">package junitcucumber;\n\nimport static org.hamcrest.CoreMatchers.is;\nimport static org.hamcrest.MatcherAssert.assertThat;\nimport static org.hamcrest.core.IsEqual.equalTo;\n\nimport cucumber.api.java.en.Given;\nimport cucumber.api.java.en.Then;\nimport cucumber.api.java.en.When;\nimport junitcucumber.User;\n\npublic class UserSteps {\n\n\tprivate User user = new User();\n\n\t@Given(\"^that the user (.*) is given a task to clear (.*) certification exam$\")\n\tpublic void certificationName(String name, String certication) throws Throwable {\n\t\tuser.setName(name);\n\t\tuser.setCertification(certication);\n\t}\n\n\t@When(\"^(.*) got (\\\\d+) marks in exam$\")\n\tpublic void gotMarks(String name, int marks) throws Throwable {\n\t\tuser.setName(name);\n\t\tuser.setMarks(marks);\n\t}\n\n\t@Then(\"^(.*) is known as (.*) certified$\")\n\tpublic void certifiedYes(String name, String certification) throws Throwable {\n\t\tassertThat(name, is(user.getName()));\n\t\tassertThat(user.getCertification(), equalTo(\"Java\"));\n\t\tassertThat(user.getResult(), is(true));\n\t}\n}\n<\/pre>\n<p>As you can see we have used <code>@Given()<\/code>, <code>@When()<\/code> and <code>@Then()<\/code> annotations for the <code>Given<\/code>, <code>When<\/code> and <code>Then<\/code> of cucumber. We can write the regular expression inside our annotations to test the scenarios.<\/p>\n<h3>4.3 Main Entry class<\/h3>\n<p>Last but not the least is the main class that runs our test cases.<\/p>\n<p><span style=\"text-decoration: underline;\"><em>UserTest.java<\/em><\/span><\/p>\n<pre class=\"brush:java;wrap-lines:false\">package junitcucumber;\n\nimport org.junit.runner.RunWith;\nimport cucumber.api.junit.Cucumber;\n\n@RunWith(Cucumber.class)\npublic class UserTest {\n}\n<\/pre>\n<p>As you see that the class is annotated with the <code>@RunWith(Cucumber.class)<\/code> class. And one more thing that needs to be noted is that the class has nothing inside it. It is bare minimum class that helps in running our tests with the Cucumber.<\/p>\n<p>When you run your test case by right clicking the above class and <code>Run As -&gt; JUnit test<\/code>, then you will see the following output in the console and the JUnit window.<\/p>\n<p><strong>Output at console<\/strong><\/p>\n<pre class=\"brush:bash;wrap-lines:false\">1 Scenarios ( [32m1 passed [0m)\n3 Steps ( [32m3 passed [0m)\n0m0.129s\n<\/pre>\n<p><strong>Output at JUnit window<\/strong><\/p>\n<p><figure id=\"attachment_44106\" aria-describedby=\"caption-attachment-44106\" style=\"width: 934px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-cucumber-example-output.jpg\"><img decoding=\"async\" class=\"size-full wp-image-44106\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-cucumber-example-output.jpg\" alt=\"JUnit Cucumber Example Output\" width=\"934\" height=\"275\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-cucumber-example-output.jpg 934w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-cucumber-example-output-300x88.jpg 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2017\/03\/junit-cucumber-example-output-768x226.jpg 768w\" sizes=\"(max-width: 934px) 100vw, 934px\" \/><\/a><figcaption id=\"caption-attachment-44106\" class=\"wp-caption-text\">Figure 3: JUnit Cucumber Example Output<\/figcaption><\/figure><\/p>\n<h2>5. Conclusion<\/h2>\n<p>In conclusion, we have seen how cucumber helps us to run the test cases with the natural language with plain english. We have also learned &nbsp;how we can test the cucumber with JUnit. Individually they are very good but when used together they will create a blast that helps the Java programmer to test his scenarios.<\/p>\n<h2>6. Download The&nbsp;Source Code<\/h2>\n<p>This is JUnit Cucumber 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\/03\/junitcucumber.zip\"><strong>JunitCucumber.zip<\/strong><\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>In this example we shall show users the usage of Cucumber with JUnit. JUnit Cucumber example will follow a brief introduction about the relation they share and how we can use both with each other. This is a very basic example and users are recommended to test their own scenarios after reading this example. After &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":[1651],"class_list":["post-44099","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-junit","tag-cucumber"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>JUnit Cucumber Example - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"In this example we shall show users the usage of Cucumber with JUnit. JUnit Cucumber example will follow a brief introduction about the relation they share.\" \/>\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-cucumber-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"JUnit Cucumber Example - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"In this example we shall show users the usage of Cucumber with JUnit. JUnit Cucumber example will follow a brief introduction about the relation they share.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-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-03-15T09:00:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-03-21T09:04:27+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=\"8 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-cucumber-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/\"},\"author\":{\"name\":\"Vinod Kumar Kashyap\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/1d6281e8235e49b5b8614621c2445d2c\"},\"headline\":\"JUnit Cucumber Example\",\"datePublished\":\"2017-03-15T09:00:22+00:00\",\"dateModified\":\"2019-03-21T09:04:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/\"},\"wordCount\":951,\"commentCount\":3,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg\",\"keywords\":[\"cucumber\"],\"articleSection\":[\"junit\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/\",\"name\":\"JUnit Cucumber Example - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg\",\"datePublished\":\"2017-03-15T09:00:22+00:00\",\"dateModified\":\"2019-03-21T09:04:27+00:00\",\"description\":\"In this example we shall show users the usage of Cucumber with JUnit. JUnit Cucumber example will follow a brief introduction about the relation they share.\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-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-cucumber-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 Cucumber 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 Cucumber Example - Java Code Geeks","description":"In this example we shall show users the usage of Cucumber with JUnit. JUnit Cucumber example will follow a brief introduction about the relation they share.","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-cucumber-example\/","og_locale":"en_US","og_type":"article","og_title":"JUnit Cucumber Example - Java Code Geeks","og_description":"In this example we shall show users the usage of Cucumber with JUnit. JUnit Cucumber example will follow a brief introduction about the relation they share.","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2017-03-15T09:00:22+00:00","article_modified_time":"2019-03-21T09:04:27+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":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/"},"author":{"name":"Vinod Kumar Kashyap","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/1d6281e8235e49b5b8614621c2445d2c"},"headline":"JUnit Cucumber Example","datePublished":"2017-03-15T09:00:22+00:00","dateModified":"2019-03-21T09:04:27+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/"},"wordCount":951,"commentCount":3,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg","keywords":["cucumber"],"articleSection":["junit"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/","name":"JUnit Cucumber Example - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2013\/11\/junit-logo.jpg","datePublished":"2017-03-15T09:00:22+00:00","dateModified":"2019-03-21T09:04:27+00:00","description":"In this example we shall show users the usage of Cucumber with JUnit. JUnit Cucumber example will follow a brief introduction about the relation they share.","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/junit\/junit-cucumber-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-cucumber-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 Cucumber 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\/44099","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=44099"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/44099\/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=44099"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=44099"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=44099"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}