Execute feature file in Cypress Cucumber

Tutorial 18​​ ​​ Execute feature file​​ in Cypress Cucumber

What you will Learn :

  • Execute and​​ Run a feature file​​ in powershell

  • Execute and​​ Run a feature file in cmd mode

Execute/Run a feature file​​ in powershell

In the previous tutorial, we had created a feature file. In this section, we will​​ see how to execute and run the feature file.​​ 

Right click the feature file and click ‘Copy Relative Path’

Now, copy the entire command mentioned below:

node_modules\.bin\cypress run --spec cypress\integration\examples\CucumberBDD\E2E.feature​​ --headed​​ --no-exit​​ --browser chrome

Note​​ 1:​​ 
--no-exit ensures that the Test runner does not close once the Test execution is complete. Thus the browser will not close after the Test is over
Note 2:​​ 
By default, the feature file runs in headless mode​​ (you wont be able to see the execution while the Test is running).​​ To see the Test running, we use --headed mode.

Open a new terminal (by default, powershell terminal) and paste the command, see below​​ ​​ ​​ 

Hit Enter, you would see Test getting executed.​​ 

Note:

When you are running cucumber feature file for the first time, it might take sometime for the Test runner to launch

See below. At the left hand side, you would see all the Gherkin syntaxes.

It is now very easy for the client to understand the steps being executed in a feature file.

Once the Test​​ is over, the below would get displayed as output


Below, we execute the same command, but this time, without​​ --no-exit. In this case, the browser closes once the Test is over. Below is the o/p​​ that would be seen once the Test is over



Execute/Run a feature file in command​​ mode

See below, by default, you see powershell​​ mode

In the visual studio, Press Ctrl + Shift + P. This would open up all the commands

Type shell​​ in the displayed text box to filter the list

Select “Terminal: Select Default Shell”

See below, you will be prompted to select your preferred terminal shell (command, powershell, bash)

Select ‘Command Prompt C:\WINDOWS\System32\cmd.exe’

Terminal > New Terminal

Now click the dropdown, you would see ‘cmd’ as well

Select cmd from dropdown

Now execute​​ the same​​ command​​ that we executed in powershell.

node_modules\.bin\cypress run --spec cypress\integration\examples\CucumberBDD\E2E.feature --headed --no-exit --browser chrome

Run, the Test runner launches and the Test gets executed, see below

Thank you​​ for reading!

 

Share On

Share on facebook
Share on twitter
Share on linkedin
Share on whatsapp
Share on tumblr
Share on email

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top

Lifetime Membership Club

LIFETIME MEMBERSHIP BIG SALE - ALL LIVE COURES JUST - 7000 RS/ 99 USD
Attend All Live courses in just 7000 rs / $99 - offer ends 1st Nov 2024