1

There is an API call like:

public int deleteGroup(String groupIdentifier) throws Exception;

I wrote a .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  |

How can I ensure that the given UID is in the database if I cannot create an entry by UID? I can create a group by name.

Dave Schweisguth
  • 36,475
  • 10
  • 98
  • 121
csikos.balint
  • 1,107
  • 2
  • 10
  • 25
  • What is the goal of this test? What do we want to verify? That the group can be deleted? Or that it can be deleted specifically by group ID? – cdlf Aug 29 '14 at 16:12
  • The goal is to verify that the any group can be deleted by its group ID. – csikos.balint Sep 01 '14 at 06:20

2 Answers2

1

Write your scenario like this:

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
  • In step 2, create the group.
  • In step 3, look up the group by name, determine its ID, and delete it by that ID.
  • In step 4, look up the group by name and assert that it isn't there.

This is a normal pattern that I've used many times. It requires some extra queries, but it relieves you of having to know IDs.

Dave Schweisguth
  • 36,475
  • 10
  • 98
  • 121
0

one of my colleague provided quite a good solution. He suggested to have a scenario like this:

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  |

With this approach I emphasize that test implementation should use delete by ID but the test method's parameter is the name. So I can create at WHEN and store its ID.

csikos.balint
  • 1,107
  • 2
  • 10
  • 25