DataSources¶
TL;DR — DataSources define named generator-backed item streams that Runner loads before sessions and assertions run.
When to use¶
Use DataSources when generated data must be reused by more than one part of a run.
- Publishers select data sources by
DataSourceNamesorDataSourcePatterns. - Other data sources can select earlier or later entries by name or pattern to chain generation.
- Assertions receive the resolved data-source list selected by their own data-source filters.
Every data source entry points to an IGenerator hook through Generator and gives that hook its configuration through GeneratorConfiguration.
YAML configuration¶
Each DataSources[] entry needs a unique Name and a Generator. The GeneratorConfiguration object belongs to the selected generator; for example, FromFileSystem reads files from GeneratorConfiguration.FileSystem.Path.
Use Lazy: true when each consumer should trigger generation as it reads. Leave it unset when Runner should cache generated items after the first retrieval. Use DataSourceNames or DataSourcePatterns when a generator needs other named data sources as input.
C# (CAC) usage¶
Code-based configuration uses DataSourceBuilder.Named(string name) and DataSourceBuilder.HookNamed(string hookName) to set the YAML-equivalent identity fields. Add the builder to Runner with ExecutionBuilder.AddDataSource(DataSourceBuilder dataSourceBuilder).
The same builder exposes Configure(object configuration), UpdateConfiguration(object configuration), AddDataSourceName(string dataSourceName), AddDataSourcePattern(string dataSourcePattern), and IsLazy() for the common DataSources fields.
Minimal example¶
DataSources:
- Name: PayloadFiles
Generator: FromFileSystem
GeneratorConfiguration:
DataArrangeOrder: AsciiAsc
FileSystem:
Path: sample-data/payloads
SearchPattern: '*.json'
StorageMetaData: ItemName
Realistic example¶
A Runner flow usually defines one file-backed data source, references it from a publisher through DataSourceNames, and references the same data source from an assertion when the assertion needs the expected payloads.
Edge cases¶
Namevalues must be unique inside theDataSourceslist.DataSourceNamescannot contain the current data source's ownName.SerializeandDeserializeare mutually exclusive on the same data-source entry.- A missing
Generatoror generator-specific required field fails configuration validation before the run starts.