Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7643813
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:32:20+00:00 2026-05-31T09:32:20+00:00

I going to test the class method which get the integer as parameter: def

  • 0

I going to test the class method which get the integer as parameter:

def step(response)
   if response < 10

I create cucumber scenario:

Scenario Outline: submit guess
    Given the code "<code>"
    When I response "<answer>"
    Then the result should be "<result>"

    Scenarios: level one
    | code | answer | result |
    |   1  |    2   |    3   |
    |   5  |    4   |    9   |

And the step difinitions:

When /^I response "([^"]*)"$/ do  | response |
  @result = @game.step(response)
end

When I’m running the test I get error, because the cucumber pass the parameter to my method as String.

How can I fix it?

I can fix the class method code:

def step(response)
   response = response.to_i
   if response < 10

but it will break all my existing code.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T09:32:21+00:00Added an answer on May 31, 2026 at 9:32 am

    Cucumber always pass string parameters to your step definitions and it is step definition responsibility to convert parameter to appropriate type. You need to do this:

    When /^I response "([^"]*)"$/ do  | response |
      @result = @game.step(response.to_i)
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I realize I'm going to get flamed for not simply writing a test myself...
I'm writing a selenium grid test suite which is going to be run on
I may be going about this backwards... I have a class which is like
I have a set of test accounts that are going to be created but
<div> <div>test</div> </div> $(div:contains('test')).css('display','none'); I know I am going to kick myself on this.
I have a ASP.NET (C#) web page which utilizes a VB class library. The
I am first going to describe the problem which I have, and then give
I have a user control which does some validation in the ValidateChildren method which
I have a non-service class which is defined as such: class A{ B b
How can I enforce that my test class covers a particular interface? Also is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.