The Data Pool commands let Action logic fetch a record from a Data Pool and use its values. One statement fetches a record, and later statements read its columns. The pool reserves the record so that no other test receives it while this test is using it. On a single-use pool, the record is marked Used when the Test Case ends, unless the logic releases it with the Release command.
Working with a record in logic takes three commands:
- Fetch a Data Pool record selects one available record and returns a reference to it.
- Get a column value from a Data Pool record reads one column of the fetched record.
- Release a Data Pool record returns a record the test did not use. This step is optional.
Commands or Parameter Binding
Parameter binding at Scenario level and the Data Pool commands in Action logic both bring pool data into a test, and most tests need only binding. A Scenario parameter bound to a pool column receives its record automatically for each Test Case, with no commands in the logic. The commands are for the cases where the logic itself has to decide which record it needs, or how many.
| The test needs | Use |
| One record of a known kind for each Test Case, such as one 5G SIM | Parameter binding |
| A record that depends on the result of an earlier step in the test, such as the rate plan of the SIM it activated | Commands |
| Several records in one Test Case, such as three SIMs for a family plan | Commands |
| A record only on one branch of the logic, such as a replacement SIM when the first activation is rejected | Commands |
Fetching a Record
Action logic gets a record only through the Fetch command. The statement identifies the pool by its ID, as shown in the Data Pools list, and specifies which kind of record is needed:
Fetch an available record from Data Pool [Prepaid SIMs ID] with Data Class 5G. Column match: none
The result is a reference to the record, not its data. Store it in a variable with a clear name, such as sim, and pass that variable to the statements that read or release the record. The report step for the fetch shows the ID of the fetched record, so the exact record a test used can be found in the pool.
Data Class: The Kind of Record
The Data Class identifies the kind of record the test needs, such as 5G, 4G or eSIM. Leave it blank to accept a record of any Data Class.
Column Match: A Record with Specific Values
A column match limits the fetch to records whose columns hold the given values. It applies together with the Data Class.
- One column: give the column and the value it must equal. Column match: one column, Region = North fetches a SIM provisioned in the North region.
- Multiple columns: give a JSON object of column names and values, such as {"Plan Code": "PP-20", "Region": "North"}. The record must match all of them.
The value in a column match is often one that an earlier step of the test produced, not a fixed value. For example, after activating a SIM, the logic can read the SIM's Plan Code and fetch the record with the same Plan Code from the Rate Plans pool, then verify the monthly fee the application shows.
When several columns have to match values held in variables, enter the column values argument as an Expression. The Expression combines the fixed parts of the JSON, such as the column names, with the variables that hold the values, such as the Plan Code and Region read earlier in the test.
Keep in mind: An encrypted column cannot be used in a column match. Data Class, Environment and Variant are not columns either: Data Class has its own argument, and Environment and Variant are covered under Record Scope below.
Record Scope: Always the Current Run
When a pool varies by Application Environment or Variant, a fetch considers only the records valid for the run it is part of. A test running in QA receives a record marked for QA or one marked for Any, and never a record marked only for UAT. The statement takes no Environment or Variant argument. A fetch always uses the Environment and Variant the test is currently running in.
Pool Type: Allocated or Only Read
A fetch behaves differently in a single-use pool and in a reusable pool.
- Single-use pool: the record moves from Ready to Allocated and is held by the current test. The status change is atomic, so tests running in parallel never receive the same record.
- Reusable pool: the record is only read. Its status does not change, and other tests can fetch the same record at the same time.
Keep in mind: When no available record matches, the statement fails and returns an empty reference. The logic continues, and statements that use that reference fail as well.
Reading Column Values
Column values are read from a fetched record one column at a time. The statement takes the record reference and a column name, and returns that column's value:
Get value of column MSISDN from Data Pool record sim
By default the result is stored in a variable named after the column. Later statements use that variable, for example to enter MSISDN in the number field and ICCID in the SIM serial field.
Keep in mind: For an encrypted column, such as a PIN, the statement returns the stored encrypted value, never the readable one. Use it only in commands whose argument accepts encrypted text. In any other command the application under test would receive the encrypted text itself.
When the Test Ends
A record fetched from a single-use pool is marked Used when the Test Case ends. This happens whether the test passed or failed, because either way the test may have changed the record in the application.
A fetched record returns to Ready only when the test logic releases it.
Keep in mind: Playback consumes records too. Each Playback of logic that fetches from a single-use pool takes a real record, and that record becomes Used just as it does in a Job run. While such logic is being built or debugged, every Playback uses one record.
Release: Returning an Unused Record
A test can fetch a record and then stop before using it. For example, an activation test fetches a SIM, runs an eligibility check on the customer, and the check fails before the activation screen is reached. The SIM is untouched, so the logic releases it and another test can use it:
Release Data Pool record sim back to the pool as Ready
The release has to run before the Test Case ends, and a test can release only a record it holds itself.
Keep in mind: Release only a record the test left untouched. A SIM that was activated and then released would be given to another test as if it were unused.
Reusable Pools: Nothing to Return
Reading a record from a reusable pool does not change its status. Nothing happens to the record when the Test Case ends, and a release has no effect.
Checking What Is Available
A test that needs several records can check how many are available before it fetches any. The count command returns how many records are in a given status, and with Ready that is the number available to fetch:
Get count of Ready records in Data Pool [Prepaid SIMs ID] with Data Class 5G, for current Environment and Variant
With the current Environment and Variant, the default, the count applies the same rule as a fetch, so it returns the number of records this run could fetch at that moment. A family-plan test that needs three SIMs can read the count first and stop with a clear message when fewer than three are Ready, instead of failing after two SIMs have already been allocated.
Keep in mind: The count is accurate only at the moment it is read. Tests running in parallel can fetch records between the count and the fetch.
Shared Pools
The commands in this article work the same in the project that owns a pool and in every project the pool is shared with. A fetch from a shared single-use pool allocates the record, and the record becomes Used or is released, exactly as in the owning project.
Commands that add, update or delete records are restricted. They run only in the pool's replenishment Job, which always belongs to the owning project.
Practical Tips
- Prefer parameter binding: bind a Scenario parameter when a Test Case needs one record of a known kind. Use the commands only when the logic has to decide which record, or how many.
- Fetch close to where the record is used: a test that fails before it reaches the fetch does not take a record from the pool.
- Name the reference after the record: variables such as sim and ratePlan keep the later Get a column value statements readable.
- Release only untouched records: once the test has changed the record in the application, let it become Used.
- Keep the pool stocked: every fetch from a single-use pool makes one record unavailable to other tests. The pool's replenishment Job adds new records.
To bind Scenario parameters to pool data instead of fetching in logic, see Use Data Pool data in your tests.
For pool types, statuses, Data Classes and Record Scope, see ACCELQ Data Pool overview and concepts.
Comments
0 comments
Please sign in to leave a comment.