首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当我使用颤振驱动程序运行测试时,没有加载资产。

当我使用颤振驱动程序运行测试时,没有加载资产。
EN

Stack Overflow用户
提问于 2019-05-22 02:17:30
回答 2查看 1.2K关注 0票数 9

当我使用颤振驱动程序运行集成测试时,我发现应用程序中的图像根本没有加载。虽然如果我运行我的应用程序从颤振运行,运行一切都很好。

这是我的测试代码:

代码语言:javascript
复制
// 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');
    });
  });
}

预期:使用颤振运行时

实际使用颤振驱动器进行运行测试时

EN

回答 2

Stack Overflow用户

发布于 2022-05-17 14:57:54

您可以看到DefaultAssetBundle文档。它描述了如何使用它和AssetBundle来提供您自己的资产。

票数 1
EN

Stack Overflow用户

发布于 2022-07-26 11:14:19

我发现了问题。对我来说,这是我在lib文件夹中运行测试的时候。一旦我将测试放在它们自己的文件夹中,与lib文件的级别相同,它就可以工作了。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56248459

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档