【问题标题】:Flutter test "FrameTimingSummarizer" error颤振测试“FrameTimingSummarizer”错误
【发布时间】:2021-05-26 16:35:34
【问题描述】:

在为颤振启动项目运行颤振测试时遇到以下问题。

命令:flutter drive --driver=test_driver/integration_test_driver.dart --target=integration_test/app_test.dart

版本

颤振:1.20.2(颤振医生没有问题), 集成测试:1.0.2+2

错误:**flutter/.pub-cache/hosted/pub.dartlang.org/integration_test-1.0.2+2/lib/integration_test.dart:324:11:错误:“FrameTimingSummarizer”不是一种类型. 最终 FrameTimingSummarizer 帧时间 = ^^^^^^^^^^^^^^^^^^^^^ /flutter/.pub-cache/hosted/pub.dartlang.org/integration_test-1.0.2+2/lib/integration_test.dart:302:20:错误:没有为“IntegrationTestWidgetsFlutterBinding”类定义获取器“kDebugWarning” '。

  • “IntegrationTestWidgetsFlutterBinding”来自“package:integration_test/integration_test.dart”(“flutter/.pub-cache/hosted/pub.dartlang.org/integration_test-1.0.2+2/lib/integration_test.dart”)。 尝试将名称更正为现有 getter 的名称,或定义名为“kDebugWarning”的 getter 或字段。 调试打印(kDebugWarning); ^^^^^^^^^^^^^ flutter/.pub-cache/hosted/pub.dartlang.org/integration_test-1.0.2+2/lib/integration_test.dart:325:9:错误:没有为“IntegrationTestWidgetsFlutterBinding”类定义方法“FrameTimingSummarizer” .
  • “IntegrationTestWidgetsFlutterBinding”来自“package:integration_test/integration_test.dart”(“flutter/.pub-cache/hosted/pub.dartlang.org/integration_test-1.0.2+2/lib/integration_test.dart”)。 尝试将名称更正为现有方法的名称,或定义名为“FrameTimingSummarizer”的方法。 FrameTimingSummarizer(frameTimings); ^^^^^^^^^^^^^^^^^^^^^ **

integration_test_driver.dart

import 'package:integration_test/integration_test_driver.dart';

void main()=> integrationDriver();

app_test.dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
import 'dart:async';
import '../lib/main.dart';

void main() {
  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
  
  testWidgets('Counter increments smoke test', (WidgetTester tester) async {
    // Build our app and trigger a frame.
    await tester.pumpWidget(MyApp());
    await tester.pumpAndSettle();

    // Verify that our counter starts at 0.
    expect(find.text('0'), findsOneWidget);
    expect(find.text('1'), findsNothing);

    // Tap the + icon and trigger a frame.
    await tester.tap(find.byIcon(Icons.add));
    await tester.pump();

    // Verify that our counter incremented.
    expect(find.text('0'), findsNothing);
    expect(find.text('1'), findsOneWidget);
  });
}


main.dart

import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
    );
  }
}

【问题讨论】:

    标签: flutter dart integration-testing flutter-test


    【解决方案1】:

    我知道这是个老问题,也许很少有人会遇到这个问题,因为问题出在颤振的旧版本上,但仅供参考,以防将来有人遇到这个问题,

    这是我对集成测试、“FrameTimingSummarizer”和颤振版本发布日期的“调查”,

    颤振 1.20.2released at Aug 14th, 2020

    FrameTimingSummarizer : created at Aug 11th, 2020,
    但是检查失败并且仅在 2021 年 10 月 1 日迁移到 flutter_test,所以我假设,基于 10 月 1 日之前发布的 flutter 1.20.2 的 flutter_test 在其库中没有 FrameTimingSummarizer 类。事实上,它似乎已经为 1.22.0 及更高版本做好了准备。

    integration_teststarting 0.9.2 他们使用 FrameTimingSummarize,
    所以很明显flutter 1.20.2不能使用integration_test 0.9.2,而且你的配置中不能使用1.0.2+2。

    结论
    Flutter 1.20.X 应该最多使用 integration_test 0.8.2。
    但是,如果您想使用 integration_test 1.0.2+2,请将 Flutter 版本至少升级到 1.22.0。它应该可以解决这个问题。

    话虽如此,我还没有自己测试过,不能保证这两种配置都没有其他问题

    希望对你有任何帮助,谢谢。

    编辑
    我已经测试了 integration_test 0.8.2 路线,它工作得很好。
    我还没有测试过flutter 1.22.0 + integration_test 1.0.2+2的思路

    编辑 2
    我已经测试了 integration_test 0.9.1,它也可以正常工作。
    所以这个版本应该是最大值而不是 0.8.2

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-11-04
      • 1970-01-01
      • 2020-12-04
      • 2019-06-08
      • 2023-01-12
      • 2018-10-30
      • 1970-01-01
      相关资源
      最近更新 更多