The load provider offers a flexible mechanism for iterative loading of fixtures and assertions. It is used for bulk updates, point-in-time restore, performance testing, and exhaustive testing of a range of permutations.
The load provider is one of the most flexible, and also one of the trickiest providers to work with. Virtually all cases require somewhat extensive use of the Rule Engine.
To facilitate working with iterative cases the Load Provider implements a number of custom functions. Judicious use of these functions is critical to successful iterative cases.
Many of the iterative functions take a "context" argument. Generally speaking, multiple calls to the same function with the same context in the same iteration will return the same value.
- RowCount(system) – Returns the number of rows in the data image of the MIM Test provider with the given name (must support data image, such as delimited, SQL, or Report provider). Use to indicate how many iterations to run the fixture or assertion for.
- Iteration() – Returns the count of the current iteration being loaded
- Row(system, field) – Returns the selected field of the current row (the row at the index of the current iteration) of the given system's data image
- Column(system, field) – Returns all values for the selected field as a List<object>
- Pick(system, field, context) – Returns a value from a random row in the data image. Use the same context to get the same row on multiple calls. Useful for generating random data, e.g. returning different parts of a random mailing address.
- PickUnique(system, field, context) – Same as pick but guarantees uniqueness using fisher-yates shuffle. The system must have more rows than the number of iterations.
- Increment(seed, interval, context) – Auto-incrementer, may be used e.g. to generate increasing fake employee IDs
- RandKey(length) – Returns a cryptographically secure random byte array of the specified length. Use for generating passwords etc.
- RandName(context) – Randomly returns one of about 30,000 names
- Rand(min, max, context) – Picks a random int 64 from min (inclusive) to max (exclusive)
- UniqueRand(min, max, context) – Returns a random number guaranteeing uniqueness within the iterations. Requires that min and max be distant enough to provide sufficient unique numbers. If the range is less than double the count it uses Fisher-Yates shuffle to avoid excessive collisions.
Fixture and Assertion
The load fixture and load assertion are virtually identical in how they are configured, the only difference is that one iterates fixtures and the other assertions. The basic structure is:
- Condition Sets
- Condition Sets
The first setting for a load operation is the number of iterations. This can be a static number, or an expression:
Next is the Memos section. Memos are particularly important for load fixtures and assertions because local memos get evaluated once per iteration. This makes it possible to pre-calculate a bunch of values, such as account name, provision flags, employee ID etc., and then use them multiple times in different sub-conditions and fixtures.
After Memos comes "Fixture Sets" or "Assertion Sets". Each set has a condition rule followed by a list of fixtures or assertions. This allows branching logic within the iteration, for example if different evaluation is required for contractors and employees, or if some assertions are site dependent.
In the final list of fixtures and assertions, any type of non-iterative fixture or assertion may be used. The only limitations are that the fixture or assertion must be defined inline (it cannot be referenced externally, although the load operation itself can), and all child fixtures execute on the same server as the parent load fixture as a single test action.
Please sign in to leave a comment.