The SentenceCSVGen Generator parses a delimited file for the following columns: Subject, Predicates, and Clause. It then creates sentences or phrases using information stored within these columns. Any delimited file (CSV, TXT, etc.) can be used with this Generator.
Note: Multiple predicate columns may be added to the file and named accordingly (predicate1, predicate2, predicate3, etc.).
In This Article
- Generator Parameters
- Preview Showing Empty Values - List Parameter
- Example Story
- Sample CSV File Data
- Using the SentenceCSVGen Generator
- Sample Output (setLoop = False)
- Sample Output (setLoop = True)
The following parameters may be configured for the SentenceCSVGen Generator. Parameters with an asterisk (*) are required.
- filePath* - The file path on your local machine where the CSV file is stored.
- fileName* - The name of the delimited file the Generator will use to create sentences or phrases.
- delimiter* - Character(s) used to separate column data in the file. The delimiter can be any type, such as a comma (,), pipe (|), or tab (\t).
- seed - Defines an optional seed for randomization. Using the seed will ensure that the same random data is generated each time data is generated as long as the values retrieved from the query are the same.
- list - Defines a list of values that will be used for preview purposes only. Three values are all that is necessary for previewing data.
- setLoop* - Defines if the Generator will produce output by applying the permutation on all the columns within the CSV file (True) or generate random sentences according to set loopCount (False). The default value is True.
- Tester - The QA Tester that wants to generate the test data.
- Sentence- The object of data needed to be synthetically generated.
- delimited file - A delimited file consisting of the subject, predicate, and clause values necessary for generating sentences.
- SentenceCSVGen Generator - Generates sentences or phrases from a delimited file.
- A Tester needs to populate a field with defect descriptions consisting of a few keywords and then populate this information into a specific location (i.e., field, database, etc.).
- A delimited file must be created with the desired subject, predicate, and clause values (see next section for a sample CSV file).
- The SentenceCSVGen Generator can then be configured to use the delimited file to create defect sentences or phrases based on this information.
Sample CSV File Data
The following is a visual example of how the delimited file should be laid out for use with the SentenceCSVGen Generator:
Using the SentenceCSVGen Generator
Step 1 - Basic Setup
- Within the GenRocket Web Platform, the Tester will create a new Project.
- Within this Project, the Tester must also create a Domain called defects.
- The Domain will contain the following Attributes, with each associated with the following Generators:
- id - RangeGen
- sentence - SentenceCSVGen
Step 2 - Replace sentence Attribute Generator
- The sentence Attribute will be assigned a default Generator when initially created.
- Select the sentence Attribute within the GenRocket web platform.
- Use the Quick Generator Replace menu on the Attribute Tab to replace it with the SentenceCSVGen Generator.
- Enter Sentence into the input field within the menu and then click on SentenceCSVGen to select this Generator.
- Click the Replace button to finish.
Step 3 - Configure the SentenceCSVGen Generator
Complete the following within the GenRocket web platform:
- Configure the filePath Parameter for the Generator. Double click on the input field, select the Resources Tab, and select the appropriate resource path.
- Click on the fileName input field and enter the name of the delimited file. For this example, it will be sentence.csv.
- Click on the delimiter input field and enter the type of delimiter (comma, pipe, tab, etc.) used to separate columns of data in the file. For this example, a comma (,) will be used.
- Since the file is stored on your local computer, preview data will not be available. Three list values must be added to see preview data in the GenRocket web platform. This is optional for previewing data.
- The setLoop Parameter determines how the output data is generated. The default value is True, which means output data will be generated by applying the permutation on all columns in the file. To generate random data based on the set loopCount, select False.
- When the setLoop Parameter is set to False, you will need to change the global.Defects.loopCount to a different value than 1 to view multiple results. In the example below, it is set to 20. This means that 20 rows will be created with the file data.
Step 4 - Add a New Receiver
Next, you must add a new Receiver to provide usable, formatted output data. For this example, we will use the DelimitedFileReceiver to create a comma-delimited text file.
Complete the following steps:
- Click the New Receiver button when viewing the Domain in the Project Dashboard.
- Enter Delimited in the Filter input field and then select DelimitedFileReceiver.
- Change the name of the Receiver (if desired) and then click Save.
- Enter a fileName for the Receiver (sentence.txt, sentence.csv, etc.). This is the name of the data file on your local computer where the output data will reside after the Scenario has been run.
- For this example, the delimiter defaults to Tab (\t) and will be changed to a comma (,). The delimiter can be changed by clicking on the input field and typing the value.
- Click the Save button to finish.
Note: You can use any desired Receiver, and this example uses a simple delimited Receiver to show how the Generator works.
Step 5 - Create and Run a Scenario
Next, you must create a quick Scenario, download it, and run it on your local computer. Complete the following steps to do so:
- Click on Quick Scenario when viewing the Domain within the GenRocket web platform. This will quickly create a Scenario including the parent and sibling relationships with referential integrity for the Domain.
- Enter a Description if desired for the Scenario and click the Save button.
- Click on the Download button when viewing the Scenario in the GenRocket web platform to download the Scenario to your local computer.
- Open a Command Window and change the directory where the output file is stored.
- Then type genrocket -r ScenarioName.grs and use the Enter Key on your keyboard to run the Scenario. In this example, the Scenario Name is DefectsScenario.grs.
- Open the output file on your computer from the command window. In this example, the file name is sentence.txt. Sample outputs are shown in the next section of this article.
Sample Output (setLoop = False)
The following provides a sample of the output created by the SentenceCSVGen Generator when the setLoop parameter is set to False.
Sample Output (setLoop = True)
The following provides an output sample created by the SentenceCSVGen Generator when the setLoop parameter is set to True.