Search code examples
bddqaf

How to manage response data of steps implemented in Gherkin using QAF API?


Looking for ways to carry over data from previous step to subsequent using QAF. Is there an option for such behavior?


Solution

  • In qaf your step can return a value. If you step is returning a value and you want to use it in another step you can use store into 'var-name' step after step that returning value. For example

    When create new user using "{'name':'user1','password':'user123'}"
    And store into 'newUser'
    Then system should have user '${newUser}'
    

    Your step may look like below:

    @QAFTestStep(description="create new user using {userInfo}")
    public User createUser(User user){
        //steps to createUser
        long id = userDao.createUser(user);
        user.setId(id);
        return user;
    }
    @QAFTestStep(description="system should have user {userInfo}")
    public void createUser(User user){
        //steps to createUser
        User user = userDao.getUser(user.getId);
        Validator.assertThat("get user from system",user, Matchers.notNull());
    }
    

    Below is example of web services test:

    Given user requests 'myservice.getuser.reqcall'
    And say 'userID' is value at jsonpath '$.id'
    Then ...