CockpitTestStepResult constructor
CockpitTestStepResult({
- required String stepId,
- required String executionId,
- required String section,
- String? description,
- String? operation,
- int? timeoutMs,
- String? definitionPath,
- required CockpitTestStepStatus status,
- required DateTime startedAt,
- required int durationMs,
- CockpitTestStepOccurrence? occurrence,
- CockpitTestSourceLocation? sourceLocation,
- CockpitTestPlane? requestedPlane,
- CockpitTestPlane? actualPlane,
- String? driverId,
- CockpitLocatorResolution? locatorResolution,
- String? degradationReason,
- CockpitTestError? error,
- Iterable<
String> evidence = const <String>[],
Creates a CockpitTestStepResult.
Implementation
CockpitTestStepResult({
required this.stepId,
required this.executionId,
required this.section,
this.description,
this.operation,
this.timeoutMs,
this.definitionPath,
required this.status,
required this.startedAt,
required this.durationMs,
CockpitTestStepOccurrence? occurrence,
this.sourceLocation,
this.requestedPlane,
this.actualPlane,
this.driverId,
this.locatorResolution,
this.degradationReason,
this.error,
Iterable<String> evidence = const <String>[],
}) : occurrence = occurrence ?? CockpitTestStepOccurrence(),
evidence = List<String>.unmodifiable(evidence) {
CockpitTestValueReader.string(stepId, r'$.stepId', id: true);
CockpitTestValueReader.string(executionId, r'$.executionId');
if (description != null) {
CockpitTestValueReader.string(description, r'$.description');
}
if (operation != null) {
CockpitTestValueReader.string(operation, r'$.operation');
}
if (timeoutMs != null && timeoutMs! <= 0) {
throw const FormatException('Step result timeoutMs must be positive.');
}
if (definitionPath != null) {
CockpitTestValueReader.string(definitionPath, r'$.definitionPath');
}
if (!const <String>{'setup', 'main', 'finally'}.contains(section)) {
throw const FormatException(
'Step section must be setup, main, or finally.',
);
}
if (durationMs < 0) {
throw const FormatException('Step durationMs cannot be negative.');
}
if (driverId != null) {
CockpitTestValueReader.string(driverId, r'$.driverId', id: true);
}
if (degradationReason != null) {
CockpitTestValueReader.string(
degradationReason,
r'$.degradationReason',
maximum: 512,
);
}
final requiresError = switch (status) {
CockpitTestStepStatus.failed ||
CockpitTestStepStatus.blocked ||
CockpitTestStepStatus.cancelled => true,
CockpitTestStepStatus.pending ||
CockpitTestStepStatus.running ||
CockpitTestStepStatus.passed ||
CockpitTestStepStatus.skipped => false,
};
if (requiresError != (error != null)) {
throw const FormatException(
'Step status and error presence are inconsistent.',
);
}
for (var index = 0; index < this.evidence.length; index += 1) {
CockpitTestValueReader.string(
this.evidence[index],
'\$.evidence[$index]',
id: true,
);
}
}