Timothy
Timothy

Reputation: 139

Cucumber Feature file does not see "step" file

This is only my second day with Cucumber. I have created the test file and the step file. Cucumber starts up and runs, but it continues to tell me to write a step file. Is there a naming convention for the files, or do I need to point to the step file somehow? I am trying to follow a tutorial.

Thank you

Cucumber: Version 3.1.0

Ruby version: 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]

rspec-core 3.7.1

 test/features/step_definitions/test_step.rb


require 'watir'
require 'colorize'

browser = Watir::Browser.new


Given(/^I am on Guru99 Demo Page$/) do

  browser.goto "http://demo.guru99.com"

 end


 When (/^Enter blank details for login$/)do
   browser.text_field(:name,"emailid").set (" ")
   browser.button(:name,"btnLogin").click 
 end

 Then (/^Show error message$/)do
   puts 'Email is Required!'.red
   browser.close
 end

And my Test File:

test/features/test.feature

Feature: guru99 Demopage Login
 In order to Login in Demopage we have to enter login details


 Scenario: Register On Guru99 Demopage without email

 Given  I am on the Guru99 homepage

 When enter blank details for Register

 Then error email shown

Here the results in the console when I run Cucumber.

ZeroCalms-MacBook-Pro:features ZeroCalm$ cucumber test.feature

Feature: guru99 Demopage Login
 In order to Login in Demopage we have to enter login details

  Scenario: Register On Guru99 Demopage without email # test.feature:5
    Given I am on the Guru99 homepage                 # test.feature:7
    When enter blank details for Register             # test.feature:9
    Then error email shown                            # test.feature:11

1 scenario (1 undefined)
3 steps (3 undefined)
0m0.026s

You can implement step definitions for undefined steps with these 
snippets:

Given("I am on the Guru{int} homepage") do |int|
  pending # Write code here that turns the phrase above into concrete 
  actions
end

When("enter blank details for Register") do
  pending # Write code here that turns the phrase above into concrete 
  actions
end

Then("error email shown") do
  pending # Write code here that turns the phrase above into concrete 
  actions
end

Upvotes: 1

Views: 831

Answers (1)

Filipe Freire
Filipe Freire

Reputation: 833

You should make the expressions on the step definitions match "exactly" the steps in the feature file.

So I am on Guru99 Demo Page on step definition is different than I am on the Guru99 homepage.

Same for Enter blank details for login, different than enter blank details for Register.

And also the same for Show error message, different than error email shown.

That's why you're getting the recommendations to implement those step definitions:

You can implement step definitions for undefined steps with these 
snippets:

Given("I am on the Guru{int} homepage") do |int|
  pending # Write code here that turns the phrase above into concrete 
  actions
end

When("enter blank details for Register") do
  pending # Write code here that turns the phrase above into concrete 
  actions
end

Then("error email shown") do
  pending # Write code here that turns the phrase above into concrete 
  actions
end

because Cucumber can't find any.

Upvotes: 1

Related Questions