[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'Integration testing' page issue #5552

Closed
neiljaywarner opened this issue Mar 26, 2021 · 5 comments
Closed

'Integration testing' page issue #5552

neiljaywarner opened this issue Mar 26, 2021 · 5 comments
Labels
p2-medium Necessary but not urgent concern. Resolve when possible.

Comments

@neiljaywarner
Copy link

Page URL: https://flutter.dev/docs/testing/integration-tests/
Page source: https://github.com/flutter/website/tree/master/src/docs/testing/integration-tests/index.md

Feature Request
Since widget and integration tests have the same API now, how do we make a directory of shared code? Seems like this would be a common request? Or maybe it's too simple, but still, documentation is so good..
https://stackoverflow.com/questions/66824928/how-do-i-make-a-shared-directory-to-share-code-in-flutter-between-integration-te

@sfshaza2
Copy link
Contributor

@johnpryan, can you address this? Thx!

@sfshaza2 sfshaza2 added the p2-medium Necessary but not urgent concern. Resolve when possible. label Mar 30, 2021
@johnpryan
Copy link
Contributor

Hi @neiljaywarner, yes you can share code that uses package:flutter_test.

You could add a file somewhere in your package (e.g. lib/my_shared_test_code.dart) and write helper functions:

import 'package:flutter_test/flutter_test.dart';

void checkForLocationString(WidgetTester tester) {
    await tester.pumpAndSettle();
    expect(find.text('Getting location...'), findsOneWidget);
}

Then you could import that file in your widget test file and integration test file using a import 'package:my_app/my_shared_test_code.dart'.

Hope this helps!

@neiljaywarner
Copy link
Author

It kinda feels like you are modifying the SUT.
But I guess it works...

Does the release build process "just work" to keep it out of the final ipa and apk

@johnpryan
Copy link
Contributor

Yes, any unused code will be tree shaken at build time. You could move the shared test code into different package if you prefer.

@neiljaywarner
Copy link
Author

@johnpryan @sfshaza2 thank you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-medium Necessary but not urgent concern. Resolve when possible.
Projects
None yet
Development

No branches or pull requests

3 participants