当我使用颤振驱动程序运行集成测试时,我发现应用程序中的图像根本没有加载。虽然如果我运行我的应用程序从颤振运行,运行一切都很好。
这是我的测试代码:
// Imports the Flutter Driver API
import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart';
void main() {
group('login page ignore', () {
// First, define the Finders. We can use these to locate Widgets from the
// test suite. Note: the Strings provided to the `byValueKey` method must
// be the same as the Strings we used for the Keys in step 1.
final ignoreFinder = find.byValueKey('ignore');
final screenFinder = find.byValueKey('child_screen');
FlutterDriver driver;
// Connect to the Flutter driver before running any tests
setUpAll(() async {
driver = await FlutterDriver.connect();
});
// Close the connection to the driver after the tests have completed
tearDownAll(() async {
if (driver != null) {
driver.close();
}
});
test('test',() async {
await driver.waitUntilNoTransientCallbacks();
await driver.waitFor(ignoreFinder);
await driver.tap(ignoreFinder);
print('button clicked');
});
});
}预期:使用颤振运行时
发布于 2022-05-17 14:57:54
您可以看到DefaultAssetBundle文档。它描述了如何使用它和AssetBundle来提供您自己的资产。
发布于 2022-07-26 11:14:19
我发现了问题。对我来说,这是我在lib文件夹中运行测试的时候。一旦我将测试放在它们自己的文件夹中,与lib文件的级别相同,它就可以工作了。
https://stackoverflow.com/questions/56248459
复制相似问题