Description

G-Data Tables dynamically call GenRocket components such as Scenarios, thus making it possible to use synthetically generated data when testing in Cucumber. 

This article shows how to add a G-Data Table to a Feature File and provides the API Function needed to use a G-Data Table.


In This Article


Prerequisites

The GenRocket components being called by the G-Data Table will need to be present within the selected Project Version. 


For this example, a User Scenario will be dynamically called to use synthetically generated data for a Cucumber test. 



Step 1: Select the G-Feature File Suite

  • Click on a G-Feature File Suite to select it. The selected suite will be highlighted in blue.


Step 2: Select the Feature File

  • Click on a Feature File to select it. The selected suite will be highlighted in blue.


Step 3: Add Keywords and Steps

  • Add Keywords and Steps that need to be present before the G-Data Table.


Step 4: Click on the G-Data Table Button

  • Click on the G-Data Table button to add a G-Data Table.


Step 5: Select Components for the G-Data Table

  • Click on the Search icon for a component.

  • Multiple components can be added to the G-Data Table (e.g., Scenario, G-Case, G-Rule).



  • Click the Plus (+) to select the component (e.g., Scenario. Scenario Chain, G-Cases).



Step 6: Save the G-Data Table

  • Click the Save button to finish.



  • The G-Data Table will appear as shown below and can be viewed in the Preview Pane.


G-Data Table API Function

An additional step must be performed if you have used a G-Data Table in a Feature File to retrieve data from a GenRocket Component (e.g., Scenario or Scenario Chain). 


To get the data while executing the G-Feature File test, you will need to make a call to the following GenRocket API function to generate the data in real-time.

GRFeatureFile.execute(List<Map<String, String>> inputs, Boolean inMemory = false, Map<String, String> resources = [:])


Sample Groovy Code:

When inMemory=false, then Scenario will be executed and data will be generated in the format as per Receiver assigned to Domain. By default, the value of the inMemory function parameter is false.

When(~'^user fills the form$') { DataTable arg1 ->
  GRFeatureFile.execute(arg1.asMaps(), true)
  //Code to read the data and execute the test further with data
}


When inMemory=true, then Scenario will be executed and data will be returned in memory in the form of Map.

When(~'^user fills the form$') { DataTable arg1 ->
  Map data = GRFeatureFile.execute(arg1.asMaps(), true)
  //Code to execute the test further with data
}