fromDynamic static method
Converts a JSON-like object to a TestStep. Whie this accepts a
dynamic
, that is because different frameworks provide different types of
JSON-like objects. So long as the given map
implements the []
operator, this will work. A value of null
will result in null
being
returned and an object that does not suppor the []
operator will result
in an exception being thrown.
The optional ignoreImages
param instructs the steps to ignore any
image attribute. This is useful if an application has a large number of
tests that need to be run. By ignoring the images, a lot of memory can
be saved.
This expects a JSON-like map object of the following format:
{
"id": <String>,
"image": <String; base64 encoded>,
"values": <Map<String, dynamic>>
}
Implementation
static TestStep fromDynamic(
dynamic map, {
bool ignoreImages = false,
}) {
late TestStep result;
if (map == null) {
throw Exception('[TestStep.fromDynamic]: map is null');
} else {
result = TestStep(
id: map['id'] ?? const Uuid().v4(),
image: map['image'] == null || ignoreImages == true
? null
: base64Decode(map['image']),
values: map['values'] == null
? null
: Map<String, dynamic>.from(map['values']),
);
}
return result;
}