【发布时间】:2021-10-11 07:50:50
【问题描述】:
我有很多具有相同背景的功能(单独的 *.feature 文件),例如: Test1.feature:
Feature: Multiple site support
Background:
Given a global administrator named "Greg"
And a blog named "Greg's anti-tax rants"
And a customer named "Dr. Bill"
And a blog named "Expensive Therapy" owned by "Dr. Bill"
Scenario: Dr.Greg posts to his own blog
Given I am logged in as Dr.Greg
When I try to post to "Some" im my blog
Then I should see "Some articles."
Test2.feature:
Feature: One site support
Background:
Given a global administrator named "Greg"
And a blog named "Greg's anti-tax rants"
And a customer named "Dr. Bill"
And a blog named "Expensive Therapy" owned by "Dr. Bill"
Scenario: Greg posts to a client's blog
Given I am logged in as Greg
When I try to post to "Expensive Therapy"
Then I should see "Your article was published.
Test3.feature:
Feature: Other site support
Background:
Given a global administrator named "Greg"
And a blog named "Greg's anti-tax rants"
And a customer named "Dr. Bill"
And a blog named "Expensive Therapy" owned by "Dr. Bill"
...
多个不同的功能文件使用相同的背景步骤,我可以将它们放在一个文件中并将它们包含在不同的场景中吗? 或者有没有更好的做法来避免在某些功能中重复相同的步骤?
【问题讨论】:
-
发布了答案。请让我知道你的 cmets。