-
Notifications
You must be signed in to change notification settings - Fork 87
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
Switch to integration tests #1461
Conversation
b09f48c
to
0fdb91a
Compare
Pull Request Test Coverage Report for Build 7667566156
💛 - Coveralls |
5e5c442
to
104dfed
Compare
9092aaa
to
0fd9cce
Compare
Dropping CHANGELOG entry as this is an internal change to how we structure our tests |
import '../../../../test/app_test.dart' as app_test; | ||
import '../../../../test/asymmetric_test.dart' as asymmetric_test; | ||
import '../../../../test/backlinks_test.dart' as backlinks_test; | ||
import '../../../../test/client_reset_test.dart' as client_reset_test; | ||
import '../../../../test/configuration_test.dart' as configuration_test; | ||
import '../../../../test/credentials_test.dart' as credentials_test; | ||
import '../../../../test/decimal128_test.dart' as decimal128_test; | ||
import '../../../../test/dynamic_realm_test.dart' as dynamic_realm_test; | ||
import '../../../../test/embedded_test.dart' as embedded_test; | ||
import '../../../../test/geospatial_test.dart' as geospatial_test; | ||
import '../../../../test/indexed_test.dart' as indexed_test; | ||
import '../../../../test/list_test.dart' as list_test; | ||
import '../../../../test/manual_test.dart' as manual_test; | ||
import '../../../../test/migration_test.dart' as migration_test; | ||
import '../../../../test/realm_logger_test.dart' as realm_logger_test; | ||
import '../../../../test/realm_map_test.dart' as realm_map_test; | ||
import '../../../../test/realm_object_test.dart' as realm_object_test; | ||
import '../../../../test/realm_set_test.dart' as realm_set_test; | ||
import '../../../../test/realm_test.dart' as realm_test; | ||
import '../../../../test/realm_value_test.dart' as realm_value_test; | ||
import '../../../../test/results_test.dart' as results_test; | ||
import '../../../../test/session_test.dart' as session_test; | ||
import '../../../../test/subscription_test.dart' as subscription_test; | ||
import '../../../../test/user_test.dart' as user_test; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is still maintained by hand for now. Integration tests can run each file separately just fine, but it is prohibitively slow to build and deploy a separate app per test file.
I have created an issue to fix this: #1490
group('app_test.dart', app_test.main); | ||
group('asymmetric_test.dart', asymmetric_test.main); | ||
group('backlinks_test.dart', backlinks_test.main); | ||
group('client_reset_test.dart', client_reset_test.main); | ||
group('configuration_test.dart', configuration_test.main); | ||
group('credentials_test.dart', credentials_test.main); | ||
group('decimal128_test.dart', decimal128_test.main); | ||
group('dynamic_realm_test.dart', dynamic_realm_test.main); | ||
group('embedded_test.dart', embedded_test.main); | ||
group('geospatial_test.dart', geospatial_test.main); | ||
group('indexed_test.dart', indexed_test.main); | ||
group('list_test.dart', list_test.main); | ||
group('manual_test.dart', manual_test.main); | ||
group('migration_test.dart', migration_test.main); | ||
group('realm_logger_test.dart', realm_logger_test.main); | ||
group('realm_map_test.dart', realm_map_test.main); | ||
group('realm_object_test.dart', realm_object_test.main); | ||
group('realm_set_test.dart', realm_set_test.main); | ||
group('realm_test.dart', realm_test.main); | ||
group('realm_value_test.dart', realm_value_test.main); | ||
group('results_test.dart', results_test.main); | ||
group('session_test.dart', session_test.main); | ||
group('subscription_test.dart', subscription_test.main); | ||
group('user_test.dart', user_test.main); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently we need to add groups manually as new test files are added (similar to how it always was).
I have created an issue to fix this: #1490
Future<void> _copyBundledFile(String fromPath, String toPath) async { | ||
final data = await rootBundle.load(fromPath); | ||
final bytes = data.buffer.asUint8List(data.offsetInBytes, data.lengthInBytes); | ||
await File(toPath).writeAsBytes(bytes); | ||
} | ||
|
||
void main() { | ||
IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | ||
|
||
// To support both dart test and flutter integration test we pass an alternative | ||
// copyFile function. Remember to add any needed files as assets in pubspec.yaml. | ||
configuration_test.copyFile = _copyBundledFile; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trick used to get rid of the duplicated flavor_helpers.dart
that are imported via relative imports.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff - only minor nits from me.
Use copyFile function variable instead, and override runtime in driver tests
Use package imports over ../lib relative imports
.. to support both flutter drive and dart test
0fd9cce
to
446d6d9
Compare
446d6d9
to
40ed4e3
Compare
40ed4e3
to
58d8617
Compare
This PR migrates to using integration tests, as recommended by the flutter team.
To run the test use:
If you run BAAS on localhost, remember that on android you should use 10.0.2.2 to reach it.
The PR also:
import '../lib/...';
) following on Avoid lib symlink #1475.You can (and should) use
--dart-define
to passBASS_URL
, etc. to the host. Tests will still read these values from the shell environment if available, that is if host and driver runs on the same node (ie. linux, macos, and windows). But you need to use--dart-define
when running on the emulators or real devices.Similar data files used in tests needs to be added as assets to the flutter tests project.
Fixes: #1465