CockpitTestCase constructor

CockpitTestCase({
  1. String schemaVersion = 'cockpit.test/v2',
  2. String kind = 'case',
  3. required String id,
  4. String? name,
  5. String? description,
  6. Iterable<String> tags = const <String>[],
  7. required CockpitTestTargetRequirements target,
  8. CockpitTestCaseDefaults defaults = CockpitTestCaseDefaults.standard,
  9. Map<String, CockpitTestVariableDeclaration> variables = const <String, CockpitTestVariableDeclaration>{},
  10. Map<String, List<CockpitTestStepTemplate>> fragments = const <String, List<CockpitTestStepTemplate>>{},
  11. Iterable<CockpitTestStepTemplate> setup = const <CockpitTestStepTemplate>[],
  12. required Iterable<CockpitTestStepTemplate> steps,
  13. Iterable<CockpitTestStepTemplate> finallySteps = const <CockpitTestStepTemplate>[],
  14. 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.');
    }
  }
}