fromDynamic static method
Creates a test from a map-like object. The map
must support the []
operator if it is not null
.
This expects a JSON-like object in the following form:
{
"active": <bool>,
"name": <String>,
"steps": <List<TestStep>>,
"suiteName": <String>,
"timestamp": <number; millis since epoch>,
"version": <number>
}
Implementation
static Test fromDynamic(
dynamic map, {
bool ignoreImages = false,
}) {
late Test result;
if (map == null) {
throw Exception('[Test.fromDynamic]: map is null');
} else {
result = Test(
active:
map['active'] == null ? true : JsonClass.parseBool(map['active']),
name: map['name'],
steps: JsonClass.fromDynamicList(
map['steps'],
(map) => TestStep.fromDynamic(
map,
ignoreImages: ignoreImages,
)),
suiteName: map['suiteName'],
timestamp: JsonClass.parseUtcMillis(
map['timestamp'],
DateTime.now().millisecondsSinceEpoch,
),
version: JsonClass.parseInt(map['version'], 1) ?? 1,
);
}
return result;
}