Search code examples
cucumbercucumber-java

Random Data in datatable cucumber


Is it possible to set unique data using datatable instead of harcoding, I need to contruct a crud UI framework where I will be creating a records then verify that records is been fetched , then updating it and verify records is been updated

Given user wants to register for new account with the following details
      | firstName             | Micheal           |
      | lastName              | Dre               |
      | email                 | [email protected]     |
      | phoneNumber           | 5555555555        |

So instead of hardcoding , as the records need to be unique for every test run Planned to user faker java library , not able to figure what is best apporoch to get this , searched varioud forum but not able to contruct same

Thanks in advance


Solution

  • The way of designing scenario doesn't looks good. You should check for other ways. However, one of the possible solution for what you are looking for is possible with qaf-cucumber using parameter with rnd prefix. Your step may look like below:

    Given user wants to register for new account with the following details
          | firstName             | Auto${rnd:aaaaa}         |
          | lastName              | ${rnd:aaa}               |
          | email                 | Auto-${rnd:aaa}@dddd.com |
          | phoneNumber           | ${rnd:9999999999}        |