Search code examples
rubycucumbergherkin

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.


Solution

  • 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)