开发者

How to pass YML-like data struct to scenario of cucumber?

开发者 https://www.devze.com 2023-01-21 19:10 出处:网络
I want to pass YML-like config data to the scenario of cucumber. for instance: category:开发者_StackOverflow中文版

I want to pass YML-like config data to the scenario of cucumber.

for instance:

category:开发者_StackOverflow中文版
  subcategory:
    name: whay

how to do this? thanks


Following a test-driven approach, consider separating the YML parsing logic from your application logic, with something like:

def my_app_logic(my_hash)
  # app logic goes here
end

def my_yml_parsing_logic
  # load a file, or get a yml string
  # parse it and return a hash
end

Then you would write unit tests to check the yml parsing logic and all its edge cases. You can also write unit tests for the app logic without having to worry about yml.

For your cucumber tests, consider mocking up (or using a factory to create) a good hash for testing, and use this hash in your step definition, so you can have a step like:

When I run my app logic on a hash with 5 categories

or something simple like that.

0

精彩评论

暂无评论...
验证码 换一张
取 消