Skip to content

Conversation

@dnfield
Copy link
Contributor

@dnfield dnfield commented Nov 10, 2020

Adds a package:integration_test test to the create template, along with a driver script for convenience when running with Flutter driver.

@jonahwilliams - this may help illustrate why/whether we want to update the drive command for integration_test tests when running them. An alternative is creating a seperate tool we publish to pub for more convenient local running - as suggested in #66264

@jonahwilliams @jiahaog @csells

@flutter-dashboard flutter-dashboard bot added the tool Affects the "flutter" command-line tool. See also t: labels. label Nov 10, 2020
@google-cla google-cla bot added the cla: yes label Nov 10, 2020
@dnfield
Copy link
Contributor Author

dnfield commented Nov 10, 2020

Addresses first item in #68818

Comment on lines 6 to 18
import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:flutter_driver/flutter_driver.dart';

Future<void> main() async {
final FlutterDriver driver = await FlutterDriver.connect();
final String data = await driver.requestData(null);
await driver.close();
final Map<String, dynamic> result = jsonDecode(data);
exit(result['result'] == 'true' ? 0 : 1);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be simplified to just

import 'package:integration_test/integration_test_driver.dart';

Future<void> main() => integrationDriver();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

// This file is provided as a convenience for running integration tests via the
// flutter drive command.
//
// flutter drive -t integration_test/app_test.dart --driver integration_test/driver.dart
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the docs, we tell people to put this file in app/test_driver/integration_test.dart. Should we move this to match?

https://pub.dev/packages/integration_test#driver-entrypoint

Also, if we're going to spell out --driver in the flag we should spell out --target as well

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather avoid having the extra directory here that might encourage people to create driver tests we'd rather they not.

TBH, I'd rather avoid having this file at all if we can come up with som ebetter way to have the tool (or a tool) run these :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense. If we don't have a tool we should definitely update the documentation to match, but I'd very much like to avoid the need for this file as well 🙂. I'll try to come up with a rough prototype next week to see if it's feasible to include an executable in package:integration_test (don't think any packages in flutter/flutter/packages do so today)


testWidgets('Counter increments smoke test', (WidgetTester tester) async {
// Build our app and trigger a frame.
app.main();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit curious about the best practice here. Is this better than calling app.main, or instead importing the root widget and using tester.pumpWidget?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

app.main will be the same regardless of what the root widget is. Whereas if you refactor your app to add a new root widget, you'd have to update the integration tests.

@dnfield dnfield requested a review from jonahwilliams December 2, 2020 19:03
@jonahwilliams
Copy link
Contributor

It would be nice if there was a test (not in the devicelab) that generated a project with the integration test option and then confirmed that it runs correctly. Will it work on the flutter-tester device?

@dnfield
Copy link
Contributor Author

dnfield commented Dec 2, 2020

Added a test in 405919f

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@fluttergithubbot fluttergithubbot merged commit d047d10 into flutter:master Dec 3, 2020
Piinks added a commit that referenced this pull request Dec 3, 2020
Piinks added a commit that referenced this pull request Dec 3, 2020
dnfield added a commit to dnfield/flutter that referenced this pull request Dec 4, 2020
dnfield added a commit that referenced this pull request Jan 15, 2021
dnfield added a commit that referenced this pull request Jan 15, 2021
* Revert "Add integration_test template to create template (#70240)"

This reverts commit d047d10.

* test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants