Description
The GenRocket API helps to update the Scenario at runtime just before execution from the user's system or server without going online and logging into the GenRocket web platform to make updates.
API methods can be used when writing code to make updates. Sometimes, the code does not have to be written to make these updates. When using G-Repository, the required updates can be accomplished using the -api command with the API method directly on the user's local computer.
This article shows the format for the API Method and how to update your Scenarios locally on your computer using the -api command.
These command-line options instruct GenRocket to override the GenRocket component's parameter values dynamically using the API Methods listed here: Index of API Methods.
In This Article
- Command
- Required Parameter
- Syntax
- Example 1 - Override Domain loopCount
- Example 2 - Override All Domain Variables
- Example 3 - Override Customer Domain loopCount in Test Data Case
Command
Include this command in the command line when running the GenRocket Scenario directly on the user's local computer.
-api
Required Parameter
The following parameter is required when using these commands:
- <engine-api> - defines the API methods that will be used
Syntax
Below is the syntax for running the command in a CMD or Terminal window:
genrocket -grepo <repoName> -grs <SCENARIO> -api <ENGINE-API>
NOTE: This syntax will vary when running a case, rule, query, etc., with a Scenario, Scenario Chain, or Scenario Chain Set. Please take a look at the following articles to see the available G-Repository commands you can use:
- -grs, --g-repo-run-scenario
- -grsc, --g-repo-run-scenario-chain
- -grscs, --g-repo-run-scenario-chain-set
- -grstryste, --g-repo-run-story-suite
- -grstryepc, --g-run-story-epic
Example 1 - Override Domain loopCount
The Customer Domain has a loopCount of '10'. However, the user wants to generate 50 records when using the G-Repository command to run a Scenario.
Command Syntax
Replace items in <> with the actual value.
genrocket -grepo <repoName> -grs <Scenario> -api "{'api': [{'methodName': 'domainSetLoopCount','parameters': {'domainName': '<domainName>', 'loopCount': '<value>'}}]}"
Example Command
genrocket -grepo SampleRepo -grs CustomerScenario.grs -api "{'api': [{'methodName': 'domainSetLoopCount','parameters': {'domainName': 'Customer', 'loopCount': '50'}}]}"
Sample Output
Example 2 - Override All Domain Variables
For this example, the user needs to modify the id, loopCount, and seed Domain Variable values and wants to change them to the following:
- id = 1010
- loopCount = 500
- seed = 11
Command Syntax
Remember to replace items in <> with the actual name.
-grepo <repoName> -grsc , <ScenarioChainName> -api "{'api': [{'methodName': 'domainSetLoopCount','parameters': {'domainName': '<domainName', 'loopCount': '<value'}}, {'methodName': 'domainVariableSet', 'parameters': {'name': 'global.<domainName>.id','value': '<value>'}}, {'methodName': 'domainVariableSet', 'parameters': {'name': 'global.<domainName>.seed', 'value': '<value>'}}]}"
Example Command
-grepo SampleRepo -grsc , AllScenarioChain.grs -api "{'api': [{'methodName': 'domainSetLoopCount','parameters': {'domainName': 'Customer', 'loopCount': '500'}}, {'methodName': 'domainVariableSet', 'parameters': {'name': 'global.Customer.id','value': '1010'}}, {'methodName': 'domainVariableSet', 'parameters': {'name': 'global.Customer.seed', 'value': '11'}}]}"
Running the above command within the CMD or Terminal Window will override the Customer Domain's global id, loopCount, and seed values and generate 500 rows of test data. The first record will have an id value of '1010'. The test data will be generated using seed number '11'.
Here is the beginning of the sample output for this example.
Since global.Customer.id was set to 1010, and 500 records were generated; the ID for the last record will be '1509'. The seed ensures that the same data will be generated each time. To learn more about seeding, click here.
Example 3 - Override Customer Domain loopCount in Test Data Case
Two Domains are present in this example: Customer and Address. The Customer Domain has a loopCount of '10' in the Test Data Case, but the user wants to generate '100' customers when running the Scenario Chain.
Command Syntax
Remember to replace values in <> with the actual value.
-grepo <repoName> -grsc , <ScenarioChainName> -tdc <CaseSuiteName.CategoryName.CaseName> -api "{'api': [{'methodName': 'domainSetLoopCount','parameters': {'domainName': '<domainName>', 'loopCount': '<value>'}}]}"
Example Command
-grepo SampleRepo -grsc , AllScenarioChain.grs -tdc SampleCases.Load.case1 -api "{'api': [{'methodName': 'domainSetLoopCount','parameters': {'domainName': 'Customer', 'loopCount': '100'}}]}"
100 customers were created