Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple feature inside single feature file

My current Cucumber file looks like this:

Feature: Test Online application Page

Scenario: Visit application home page and test links

Scenario: Visit application Login and Validate login

So now I would like to add few more scenarios may be for API testing in the same file. So i was thinking to create a new Feature for that instead of using the Feature: Test Online application Page. This way i dont need to create a separate feature file for API testing.

Feature: Test Online application Page

     Scenario: Visit application home page and test links

     Scenario: Visit application Login and Validate login

Feature: Test application API's

    Scenario: validate Login API

Is it possible to have multiple features within a single feature file and is that a good practice? I just need to test one API and I will run API tests along with online tests. I will still separate them using @online and @api tags.

like image 539
Sunilkumar V Avatar asked Jun 02 '15 15:06

Sunilkumar V


People also ask

Can we have 2 features in one feature file?

Feature file can contain multiple scenarios or scenario outlines. We can write all possible Scenarios of a particular feature in a feature file. By using the keyword "Scenario" or "Scenario Outline", One Scenario can be separated from another.

How do you run multiple scenarios in a single feature file?

You can execute multiple scenarios in a single or multiple feature file by tagging Scenarios with common tags or grouping them using the rule keyword and tags. And Later, you can execute the scenarios by using that tag in the Cucumber Runner or Command line.

How many features can be created in single feature file?

The extension of the feature file needs to be “. feature”. One can create as many feature files as needed.

Can a feature file have multiple tags?

Also, a tag which is used for a feature shall be inherited by all its Scenarios and the Scenario Outlines. Tags are placed before a Scenario or a Feature that we want to tag. We can also have multiple tags which are separated by spaces within a line.


1 Answers

It is not possible to have multiple feature inside single feature file. If you create multiple feature inside single feature file, you will get Gherkin Parser exception while running cucumber scenarios. So the answer is NO.

C:/Users/ABC/RubymineProjects/XYZ.feature: Lexing error on line 47: 'Feature test google'. See https://github.com/cucumber-attic/gherkin2/wiki/LexingError for more information. (Cucumber::Core::Gherkin::ParseError)
like image 78
Sunilkumar V Avatar answered Oct 17 '22 01:10

Sunilkumar V