How to handle running cucumber features within Ruby method -


i using afterconfiguration hook run setup config before tests start, issue faced when run methods 1 of them run set of feature files using backticks in ruby method, in turn seems re initialze cucumber , repeat process, stuck in loop

afterconfiguration     environmentsetup::testusers.create_test_users end  module environmentsetup   class testusers     def self.create_test_users     # other logic here     `cucumber "#{path_to_feature}"` # use backticks run cucumber scripts in subshell     end    end end 

so when executed goes beginning , runs other logic again

is there way run once, or ignore afterconfiguration on second loop? declare global variable?

i have tried

afterconfiguration   if defined? $a == nil    environmentsetup::redisusers.check_redis_users    environmentsetup::testusers.create_test_users  end 

end

module environmentsetup   class testusers     def self.create_test_users     # other logic here     $a = true     `cucumber "#{path_to_feature}"` # use backticks run cucumber scripts in subshell     end    end end 

but im guessing variable set not being carried across when re initializing?

any assistance appreciated

thanks

try setting environment variable:

afterconfiguration   return if env['cucumber_configured'] == 'yes'    environmentsetup::testusers.create_test_users   env['cucumber_configured'] = 'yes' end 

and run cucumber this:

cucumber_configured='no'; cucumber ... 

Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -