Wednesday, March 1, 2017

How to write multiple test cases in Selenium with Cucumber?

In this post we will learn about writing multiple test cases (Scenarios) in a Feature file. This post is going to be an extension to the previous post First Test Case in Selenium with Cucumber. So please go through it to understand the current post better. Let's get started step by step...

Step 1: This time we are taking "Gmail valid login validation" as our test. Please copy the below code snippet in our feature file created "gmailLogin.feature" file and save it.


Step 2: Now go to TestRunner.java Right click > Run As > Junit Test

Step 3: Check out the Junit results, The first scenario is executed and passed but the second scenario is stopped at the 3rd step in the second scenario and failed. This because the last three steps are missing in the Step Definitions.

In the console we will find the three missed steps, add the three in step definitions file and define their functionalities.

Step 4: Add the steps in Step Definition file and define their actions.

Step 5: Go to TestRunner.java Right click > Run As > Junit Test.

Step 6: Check out the Junit results now, two scenarios are executed successfully and are Passed also.

This is how we can add multiple tests in the feature file. And we need not execute all the scenarios for adding a new scenario. Comment all the previous scenarios > add the new scenario and run it as Junit test > add missed step definitions. That's how we can add the multiple scenarios.

9 comments:

  1. Thank you for taking the time and sharing this information with us. It was indeed very helpful and insightful while being straight forward and to the point.
    Selenium certification training

    ReplyDelete
  2. Individuals will become a skilled writer only writing and writing some more. Further, writing is not a linear process. It is messy and frequently, time consuming.resume template

    ReplyDelete
  3. Great job for publishing such a beneficial web site. Your web log isn’t only useful but it is additionally really creative too. type my essay

    ReplyDelete
  4. Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I'll be subscribing to your feed and I hope you post again soon. Big thanks for the useful info. essay writing services

    ReplyDelete

DevOps 01: What is DevOps and How it benefits organizations?

DevOps is a culture in an organization, where the development team and operations team help each other by sharing information, process and t...