cucumber / cucumber/cucumber-ruby

Scenario outline Table Value is Getting Cloned on Each Run

Open
#1,553 4 comments 0 reactions 0 assignees View on GitHub
:bug: bug :hourglass: stale :vertical_traffic_light: needs tests
Dominant language
Ruby
Stars
5.2k
Forks
1.1k
Avg merge
1d 16h
Merged PRs (30d)
3

Description

**Describe the bug**
Scenario Outline table value gets appended to the previous iteration value when the table values are same using `<<` operator

**To Reproduce**
Feature file -
```
Feature: Testing City Names

Scenario Outline:
And I live in '' City
And I am not from ''

Examples:
| city |
| Sacramento |
| Sacramento |
```
Step Definition file -
```
And 'I live in {string} City' do |city|
city << ' City'
puts "#{city}"
end

And /^I am not from '(.+)'$/ do |city|
city << ' city'
puts "#{city}"
end
```
gemfile -
```
source 'https://rubygems.org'

gem 'cucumber', '~> 6.1.0'
```

**Expected behavior**
Should be
loop 1
```
I live in Sacramento City
I am not from Sacramento city
```
loop 2
```
I live in Sacramento City
I am not from Sacramento city
```

**Context & Motivation**
This fails Cucumber feature plans in our automation suite. To fix it right now we are updating `<<` with `+=` but would be great to have `<<` working to append strings.

**Screenshots**
![image](https://user-images.githubusercontent.com/9060416/122450987-8594e280-cf5c-11eb-8c95-324e254d19f5.png)

**Your Environment**
- Versions used: Cucumber 6.1.0 and Ruby 2.6.4
- Operating System and version: Windows 10 64bit

**Additional context**
When Cucumber is downgraded to 6.0.0 `<<` does not clone/append strings and works fine
When I use Cucumber Expressions in step definition I can't reproduce the issue it's only when I use regular expression.
And when table values are not same this issue cannot be reproduced

Contributor guide

Open the contributing guide

Research direction

Start by running the supplied feature file and step definitions with Cucumber 6.1.0, then compare the behavior with 6.0.0. Trace scenario outline values passed to regular-expression steps and add a regression test showing that identical values do not retain mutations between runs; done means both loops print the expected unappended strings.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
testing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.