有一个API调用,如:
public int deleteGroup(String groupIdentifier) throws Exception;
我写了一个.feature:
Scenario: Deleting an existing group (by its ID) successfully
Given I am authorized
And <groupid> is already stored in WAAD
When I call the delete group method for group <groupid>
Then group <groupid> should NOT be present in WAAD
Examples:
| groupid |
| test.group1 |
| test.group2 |
如果我无法通过UID创建条目,如何确保给定的UID在数据库中?我可以按名称创建一个组。
答案 0 :(得分:1)
像这样编写你的场景:
Scenario: Deleting an existing group (by its ID) successfully
Given I am authorized
And a group named "whatever" is already stored in WAAD
When I call the delete group method for the group named "whatever"
Then the group named "whatever" should NOT be present in WAAD
这是我多次使用的正常模式。它需要一些额外的查询,但它让您不必知道ID。
答案 1 :(得分:0)
我的一位同事提供了很好的解决方案。他建议有这样的场景:
Scenario: Deleting an existing group (by its Id) successfully
Given I am authorized
And <groupname> is already stored in WAAD
When I call the delete group method for group with <groupname> by its ID
Then group <groupname> should NOT be present in WAAD
Examples:
| geroupname |
| test.group1 |
| test.group2 |
通过这种方法,我强调测试实现应该使用按ID删除,但测试方法的参数是名称。所以我可以在WHEN创建并存储其ID。