What is Gherkin syntax and how it works

Rahul Shetty
A free video tutorial from Rahul Shetty
Teacher/Founder of RahulShettyAcademy.com (Testing School)
4.5 instructor rating • 17 courses • 298,950 students

Learn more from the full course

Cucumber with Java-Build Automation Framework in lesser code

Step by Step Cucumber BDD Approach to design the powerful Testing framework(Selenium,Appium,API) with very MINIMALCODE

10:40:37 of on-demand video • Updated November 2020

  • By end of this course , You will be able to develop Cucumber Test Framework for any Web/Mobile/API Automation testcases
  • Understand how BDD(Behaviour driven development) approach works with the knowledge of gherkin syntax
  • Indepth understanding of real time Automation framework challenges and solutions to fix them
  • Complete knowledge on Datadriven testing, Parameterizations, Resuable components, Cucumber hooks and tags
  •  Additional knowledge on Integrating Cucumber framework with MAVEN, JENKINS, GITHUB
English [Auto] Welcome back. So let's start understanding a few terminologies regarding this Google model. The first thing is Gerkin. So war is jerky. So basically it is in language to describe the software behavior. So in testing done so to speak its own language to define the test case. OK in general if you want to develop or if you want something you're right it has to guess in plain English right. Like check top credit card payment article loan payment. So it's all over. Go and click on the link verifying that information is being sent. Click on submit. Check the confirmation page is displayed. So you write a pretty plain test guess if you want to test any software behavior by so doing this. There are some problems with this design. OK. So dickin is replaces and fixes all that disadvantageous we are having with existing uploads are fighting this cases in plain English. OK. Now for example let me write a test case here. OK. This is all I needed in an example I will read on this. So this is a play in this case. If you want to write like a pop up message is displayed when buttons are clicked and had also gone. OK so this is the text given by the business analyst. So let's assume that we all know that business analyst is the guy who will give us requirements business requirements. OK. Based on business requirements given by B. Q I will go and write this gets us based upon that requirements. OK. So in one of their requirements this is a want. He has given. So when you write something in plain English that would present the interpretation of that line could be different for a different person. Ok be as norms are interpreted in one way. But when Q Is the this you might interpret this in another way. Well good because there is no one single or common syntax to stick to a particular language. So here it's up to the people. So based upon his proficiency in English people define something like you see here a big one to write like this pop up message is displayed when buttons are click OK and then edits are gone. This is what he will talk of giving requirement. So one way or interpreting this is powerful message is displayed. Then buttons clicked and then it was gone. So both of this is displayed and the gone on button. When clicking on a button. The message is displayed. And others at us are gone. This is how he interpreted and written Putman to edit this. His vision could be different. In reading this plain-English Now you can also read this as both openness it's you displayed only when buttons are clicked and the rules are carefully observe these two lines. No OK here. What is top of this line is pop up message will only display when I click the button and all the errors are done. OK. So he has to make sure all the errors are not present in the page and then he clicks the button. So that pop up message is displayed. OK that two conditions has to wait to display pop up message. That's what you interpret and never be. He's saying that on button clicked automatically. Those are gone and pop up message comes up. So which is correct. And if you read this clearly you are confused. OK. Just pass this video and try to understand. So with a plain english language it's what generally are traditionally people using in the market. They could be wrong in interpreting that. OK. When Business Analyst give this they will refer to me as this in this style and he will play this ok. Q It may be zooming in this fashion and doing a test case in this way so that of course the mismatch and he will be raising an issue once you see that in the production and thereafter he would be if it passes along. And if it's already late and before leaving the project then that is something that's ok if at least let's assume that developer made a mistake. If Q is correct then he could correct it and he can raise a defect. And that is not a big B but if Q8 interpreted in the wrong way and they will have but also interpreted in the wrong way then what happens. It goes into the line but when they started argument and you know everyone have their own version. So that is why people generally put in meetings as a sign off will come whenever they developed their skill sets. They get sign of signed off that this gives us a window business and at least that's what people traditionally do to overcome this problem. So However there are some minor Your problems are still going on in understanding us the way people are writing. So to overcome this disadvantageous if we all come into a common platform of showing or describing software behavior then there is no point of misleading from actual behavior. OK. So this is where Denton comes in the picture. So if B.A. wants to write or wants to show a software business requirement he has to define doc in Gerkin syntax so it can define some standards where if he used dot standards in describing this best guess then it would be very clear for all of us to interpret it that. OK. That is where this comes into picture. And we say as a BTD behavioral driven development where we explicitly defined the behavior of software requirement using this second language. So it could be also serve as a business cleanable and domain specific language so you will be seeing here Hoku exactly right I guess index. So here I just want to throw a light on what is to Kim and I hope you understand this example of misleading interpretation. Right. So that is one main thing and the key words which you frequently see in cucumber are scenario future feature film scenario outline and step definition these key words you will commonly see when you're working with cucumber automation or if you go to any interview. Obviously the really big question from one of the skewer. OK. What is does and how it works. That's a common thing. So these two will specifically concentrate when we are working on real or imagined things. Ok now I want to concentrate on these three parts. So first want is seen audio in cucumber test cases are presented as scenarios. OK we generally call them in terms of scenarios instead of a test case. So in traditional board we see it as a best guess but when we are dealing with combat we should see it as a scenario because this is how we use a keyword in that framework. Now so as I said this is a test case and this test case should be presented in Durkin's type isn't it. So each and every scenario is nothing but it can language. So what what do you want to express. You need to express that to him. Now what does Delkin begs as an import and how do you define it what the syntax. OK let's understand these three items. So when you want to write a test case now for example I have something here. Let me take that I'll take this. And I and paste it here. OK you know this bullet points are. Given it's an give and use of fools and then okay now. So here are the business requirement. Our vets want to express is making a car payment with many months by selecting a minimum amount option. OK when you want to make a card payment. If you really do in your real time you know this. So if you want to make any credit card payment you will have an option to pay a minimum do or you will have an option to best complete statement balance or you will also have an option to pay either the amount and you can mention them on the net. So any of these three fields you have to use to be able to get Kraker. So here let's assume that functionality is to check if minimum amount minimum payment flow is working or not. OK. If credit card bill is about $500 and $24 you're in my basement. So there is an option to select the minimum payment and you have to pay that 25. So this is a functionality which you need to verify. So to express this to experts and to define this because software behavior can use this three Keyworth here given then and then. OK so given is this what are the preconditions like before you begin testing this functionality. What you need to know are what do you have to fulfill. OK in this case to fulfill this credit card payment first of all you should be on paid in that garbage. OK. This is a requirement. So here you are the business is clearly telling that from which page you can test this functionality. OK if you're simply simply let go and make the credit card payment credit card payment maybe from multiple pages. OK. When you launch or when you get to your banking same credit card payment could be from the left side not the navigation links. Or you can access it from credit card app or there could be any link in the form that pays for that instant a click link references to big they've got it. So first we need to understand on which type of business model we are testing this fall that he has to provide a given like preconditions are mentioned. So given user is on can a guard beat. Next when so next is once you are on that base with preconditions fulfilled. Now to make this payment what action you need to perform. Well that stands that even the purpose of any is to discredit use that action to make this payment happen. What of the actions you need to perform when user files are details OK he has to obviously feel that did you are making payment and with from we check on and then he should select minimum amount option you're selected. And for this when it did make people use that actions you can comfortably use and OPERATOR OK you can use any keyword and you can concatenate all you actions under this then. OK. That's why I want all the details of food and minimum amount. Option is given and use that we go and click on Fabletown. Obviously he has to do that. This is an action. And then what is that result. OK so once you fulfill the conditions and walk off that he makes a payment and then what is the purpose of this flow. That is right. That result should be written in then key word here then stands for the purpose of then step is to observe that expected output here gray card confirmation page is displayed. This is our expected output. You'll see that Simberg scarce making minimum bet Do amount. Great God. If they want to express that he can just write in one single line but from there we will have a lot of questions like from which navigation we have to go. What is the flow and what is the outcome expected. So all of these if they fine in this fashion and how cool it is to test this isn't what we see as a behavioral drive and development. Okay so given them the test requirement is very very clear here. So in cucumber this way of writing it best guess as far as Snoddy. OK so one caution please remember Doug Don't assume that if business analyst does not give you gifts in this way you can do it with cucumber. Okay here give giving you given your simple plain text of what I have shown here. If you want to or don't make you want to guess you can you will take selenium test if it is over best. OK. So if you want be a spokesman for him but make sure you convert this test to guess in this fashion. You'll be fine as an artificial tester when you have quite a single baseline reading that requirement. And obviously when you want to make something you have to start from the page from there you want to navigate and you have to up on them in all directions and you need to get right by using sessions. So first can we do this to get us into this more then. And then you can use to combat our donation to our premature excuses OK. So just don't think that if you are to be or if your manager or whoever gives your best guess is not in standard you cannot use them but because mostly people say that we don't get like this so can't they use cucumber. OK you can use cucumber for sure. Just convert this test whatever you got as a plain English. This is a simple step right right in your own fashion. And then you can happily argument with them. OK. So let's continue on in our next lecture. Thank you.