CockpitTestCase constructor
CockpitTestCase({
- String schemaVersion = 'cockpit.test/v2',
- String kind = 'case',
- required String id,
- String? name,
- String? description,
- Iterable<
String> tags = const <String>[], - required CockpitTestTargetRequirements target,
- CockpitTestCaseDefaults defaults = CockpitTestCaseDefaults.standard,
- Map<
String, CockpitTestVariableDeclaration> variables = const <String, CockpitTestVariableDeclaration>{}, - Map<
String, List< fragments = const <String, List<CockpitTestStepTemplate>>{},CockpitTestStepTemplate> > - Iterable<
CockpitTestStepTemplate> setup = const <CockpitTestStepTemplate>[], - required Iterable<
CockpitTestStepTemplate> steps, - Iterable<
CockpitTestStepTemplate> finallySteps = const <CockpitTestStepTemplate>[], - Map<
String, Object?> extensions = const <String, Object?>{},
Creates a CockpitTestCase.
Implementation
CockpitTestCase({
this.schemaVersion = 'cockpit.test/v2',
this.kind = 'case',
required this.id,
this.name,
this.description,
Iterable<String> tags = const <String>[],
required this.target,
this.defaults = CockpitTestCaseDefaults.standard,
Map<String, CockpitTestVariableDeclaration> variables =
const <String, CockpitTestVariableDeclaration>{},
Map<String, List<CockpitTestStepTemplate>> fragments =
const <String, List<CockpitTestStepTemplate>>{},
Iterable<CockpitTestStepTemplate> setup = const <CockpitTestStepTemplate>[],
required Iterable<CockpitTestStepTemplate> steps,
Iterable<CockpitTestStepTemplate> finallySteps =
const <CockpitTestStepTemplate>[],
Map<String, Object?> extensions = const <String, Object?>{},
}) : tags = Set<String>.unmodifiable(tags),
variables = Map<String, CockpitTestVariableDeclaration>.unmodifiable(
variables,
),
fragments = Map<String, List<CockpitTestStepTemplate>>.unmodifiable(
<String, List<CockpitTestStepTemplate>>{
for (final entry in fragments.entries)
entry.key: List<CockpitTestStepTemplate>.unmodifiable(entry.value),
},
),
setup = List<CockpitTestStepTemplate>.unmodifiable(setup),
steps = List<CockpitTestStepTemplate>.unmodifiable(steps),
finallySteps = List<CockpitTestStepTemplate>.unmodifiable(finallySteps),
extensions = CockpitTestValueReader.extensions(
extensions,
r'$.extensions',
) {
if (schemaVersion != 'cockpit.test/v2') {
throw const FormatException(
'schemaVersion must be exactly cockpit.test/v2.',
);
}
if (kind != 'case') {
throw const FormatException(
'Only kind case is supported by this runtime.',
);
}
CockpitTestValueReader.string(id, r'$.id', id: true);
if (name != null) {
CockpitTestValueReader.string(name, r'$.name');
}
if (description != null) {
CockpitTestValueReader.string(description, r'$.description');
}
for (final tag in this.tags) {
CockpitTestValueReader.string(tag, r'$.tags');
}
for (final name in this.variables.keys) {
CockpitTestValueReader.string(name, r'$.variables', id: true);
}
if (this.steps.isEmpty) {
throw const FormatException('A case requires at least one main step.');
}
for (final fragment in this.fragments.entries) {
CockpitTestValueReader.string(fragment.key, r'$.fragments', id: true);
if (fragment.value.isEmpty) {
throw FormatException('Fragment ${fragment.key} cannot be empty.');
}
}
}