text
stringlengths 1
372
|
|---|
}
|
<code_end>
|
the integrationDriver function has a responseDataCallback
|
which you can customize.
|
by default, it writes the results to the integration_response_data.json file,
|
but you can customize it to generate a summary like in this example.
|
<topic_end>
|
<topic_start>
|
4. run the test
|
after configuring the test to capture a performance timeline and save a
|
summary of the results to disk, run the test with the following command:
|
the --profile option means to compile the app for the “profile mode”
|
rather than the “debug mode”, so that the benchmark result is closer to
|
what will be experienced by end users.
|
info note
|
run the command with --no-dds when running on a mobile device or emulator.
|
this option disables the dart development service (dds), which won’t
|
be accessible from your computer.
|
<topic_end>
|
<topic_start>
|
5. review the results
|
after the test completes successfully, the build directory at the root of
|
the project contains two files:
|
<topic_end>
|
<topic_start>
|
summary example
|
<topic_end>
|
<topic_start>
|
complete example
|
integration_test/scrolling_test.dart
|
<code_start>
|
import 'package:flutter/material.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
import 'package:integration_test/integration_test.dart';
|
import 'package:scrolling/main.dart';
|
void main() {
|
final binding = IntegrationTestWidgetsFlutterBinding.ensureInitialized();
|
testWidgets('Counter increments smoke test', (tester) async {
|
// build our app and trigger a frame.
|
await tester.pumpWidget(MyApp(
|
items: List<String>.generate(10000, (i) => 'item $i'),
|
));
|
final listFinder = find.byType(Scrollable);
|
final itemFinder = find.byKey(const ValueKey('item_50_text'));
|
await binding.traceAction(
|
() async {
|
// scroll until the item to be found appears.
|
await tester.scrollUntilVisible(
|
itemFinder,
|
500.0,
|
scrollable: listFinder,
|
);
|
},
|
reportKey: 'scrolling_timeline',
|
);
|
});
|
}
|
<code_end>
|
test_driver/perf_driver.dart
|
<code_start>
|
import 'package:flutter_driver/flutter_driver.dart' as driver;
|
import 'package:integration_test/integration_test_driver.dart';
|
future<void> main() {
|
return integrationDriver(
|
responseDataCallback: (data) async {
|
if (data != null) {
|
final timeline = driver.Timeline.fromJson(
|
data['scrolling_timeline'] as Map<String, dynamic>,
|
);
|
// convert the timeline into a TimelineSummary that's easier to
|
// read and understand.
|
final summary = driver.TimelineSummary.summarize(timeline);
|
// then, write the entire timeline to disk in a json format.
|
// this file can be opened in the chrome browser's tracing tools
|
// found by navigating to chrome://tracing.
|
// optionally, save the summary to disk by setting includeSummary
|
// to true
|
await summary.writeTimelineToFile(
|
'scrolling_timeline',
|
pretty: true,
|
includeSummary: true,
|
);
|
}
|
},
|
);
|
}
|
<code_end>
|
<topic_end>
|
<topic_start>
|
testing plugins
|
all of the usual types of flutter tests apply to
|
plugin packages as well, but because plugins contain
|
native code they often also require other kinds of tests
|
to test all of their functionality.
|
info note
|
to learn how to test your plugin code, read on.
|
to learn how to avoid crashes from a plugin when
|
testing your flutter app, check out
|
plugins in flutter tests.
|
<topic_end>
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.