flutter - 颤振测试“FrameTimingSummarizer”错误
问题描述
在为颤振启动项目运行颤振测试时,我面临以下问题。
命令 :flutter drive --driver=test_driver/integration_test_driver.dart --target=integration_test/app_test.dart
版本
Flutter:1.20.2(flutter Doctor没有问题),integration_test: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 frameTimes = ^^^^^^^^^^^^^^^^^^^^ /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);
});
}
主要.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),
);
}
}
解决方案
I know it's old question and maybe rarely people will face this since the problem lies on the flutter old version, but just for reference in case anyone face this problem in the future,
so here is my "investigation" about integration test, "FrameTimingSummarizer", and flutter version release date,
flutter 1.20.2 : released at Aug 14th, 2020
FrameTimingSummarizer : created at Aug 11th, 2020,
but there are failing check and only migrated to flutter_test at Oct 1st, 2021, so I assume, flutter_test base on flutter 1.20.2 which is released prior to Oct 1st, doesn't have FrameTimingSummarizer class in its library. In fact it seems to be prepared for 1.22.0 and up.
integration_test : starting 0.9.2 they use FrameTimingSummarize,
so it obvious that flutter 1.20.2 cannot use integration_test 0.9.2, moreover 1.0.2+2 in your configuration.
Conclusion
flutter 1.20.X should use integration_test 0.8.2 at max.
but, if your want to use integration_test 1.0.2+2, please upgrade flutter version to at least 1.22.0. it should solve this problem.
with that being said, I haven't test it my self, and cannot guarantee that there are no other issue about both of the configurations
I hope it can help you in any way, thank you.
EDIT
I have tested the integration_test 0.8.2 route and it work just fine.
I still haven't test the flutter 1.22.0 + integration_test 1.0.2+2 thought
EDIT 2
I have tested the integration_test 0.9.1 and it work fine too.
so this version should be the max instead of 0.8.2
推荐阅读
- hybris - 使用 spartacus 的 SAP Hybris 商务生产
- python - 在 Django 中使用中间模型属性访问字段
- java - Java 11:从泛型类型创建类实例
- python - 如果值小于 x,Pandas 检查 2 个数据集创建显示 ture/false 的新表
- python - 珊瑚边缘 TPU 分类坐标
- reactjs - Apollo:graphql 错误后如何处理缓存?
- amazon-web-services - Ansible 通过跳转服务器从主机 ping 到远程服务器时出错
- django - Django - 使用 ReportLab 创建了一个 pdf 文件,但我如何将它存储到 FileField 记录中?
- python-3.x - 更改列表中的一个值会影响方法内数据框单元格的值的原因是什么?
- wso2esb - POST 基本身份验证 API HttpEndpoint Wso2 EI