Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Testing codemagic中的颤振测试资源_Testing_Flutter_Continuous Integration_Codemagic - Fatal编程技术网

Testing codemagic中的颤振测试资源

Testing codemagic中的颤振测试资源,testing,flutter,continuous-integration,codemagic,Testing,Flutter,Continuous Integration,Codemagic,我想在颤振测试中使用JSON文件模拟HTTP响应。在gitlab CI上,测试正在通过。也在当地。但是在codemagic.io上有一个错误: FileSystemException:无法打开文件,路径='test\u resources/mock\u response.json'(操作系统错误:没有这样的文件或目录,errno=2)这与。由提供的解决方案为我工作 例如,你可以有这样的东西: import 'dart:io'; import 'package:path/path.dart';

我想在颤振测试中使用JSON文件模拟HTTP响应。在gitlab CI上,测试正在通过。也在当地。但是在codemagic.io上有一个错误:

FileSystemException:无法打开文件,路径='test\u resources/mock\u response.json'(操作系统错误:没有这样的文件或目录,errno=2)

这与。由提供的解决方案为我工作

例如,你可以有这样的东西:

import 'dart:io';
import 'package:path/path.dart';

String loadResource(String name) => File("$_testDirectory/test_resources/$name").readAsStringSync();

// From https://github.com/flutter/flutter/issues/20907#issuecomment-466185328
final _testDirectory = join(
  Directory.current.path,
  Directory.current.path.endsWith('test') ? '' : 'test',
);
然后使用它:

final mockResponse = loadResource('mock_response.json');