copyResourceTo function
Copies the test resource at the specified path
into the provided File
,
creating it if necessary.
"Test resources" are files stored (by default) under the test/resources/
directory of the project root. This prefix may be changed, using the
prefix
argument.
Arguments
String path
- the relative path (from theprefix
by default).File file
- the file which will be a copy of the resource file data.String prefix
- the path prefix from the project root (defaults totest/resources
).
Implementation
void copyResourceTo(String path, File file, {String prefix = _defaultPrefix}) {
final sourceFile = resourceFile(path, prefix: prefix);
if (!sourceFile.existsSync()) {
throw Exception('Resource file ($path) does not exist.');
}
file.parent.createSync(recursive: true);
sourceFile.copySync(file.path);
}