我是Appium的新手,我不知道Background:
在Appium的.feature
文件中做了什么。有人可以向我解释一下吗?
根据我的理解,每次在一个场景结束后执行Background:
下的测试步骤。
答案 0 :(得分:0)
要素文件中的背景部分允许您指定一组步骤 对于文件中的每个方案都是通用的。因此,不必为每个场景反复重复这些步骤,您可以将它们移动到背景中 元件。
这样做的好处是:
例如,考虑以下两种情况:
Scenario: Change PIN successfully
Given I have been issued a new card
And I insert the card, entering the correct PIN
When I choose "Change PIN" from the menu
And I change the PIN to 9876
Then the system should remember my PIN is now 9876
Scenario: Try to change PIN to the same as before
Given I have been issued a new card
And I insert the card, entering the correct PIN
When I choose "Change PIN" from the menu
And I try to change the PIN to the original PIN number
Then I should see a warning message
And the system should not have changed my PIN
从上述2个场景中,您可以看到前几个步骤在每个场景中重复出现。所以我们可以做的是将它们移到后台,然后它们将在每个场景的开头自动执行。
Background:
Given I have been issued a new card
And I insert the card, entering the correct PIN
And I choose "Change PIN" from the menu
Scenario: Change PIN successfully
When I change the PIN to 9876
Then the system should remember my PIN is now 9876
Scenario: Try to change PIN to the same as before
When I try to change the PIN to the original PIN number
Then I should see a warning message
And the system should not have changed my PIN