Skip to content

Instantly share code, notes, and snippets.

@aam
Last active June 25, 2019 14:51
Show Gist options
  • Save aam/5532a5fff95555fe1ab5e4ca66bea043 to your computer and use it in GitHub Desktop.
Save aam/5532a5fff95555fe1ab5e4ca66bea043 to your computer and use it in GitHub Desktop.
Check if flutter testWidgets supports multiple isolates
import 'dart:async';
import 'dart:isolate';
import 'package:flutter_test/flutter_test.dart';
void main() {
testWidgets('Headers', (WidgetTester tester) async {
final Completer<String> completer = Completer<String>();
final RawReceivePort receivePort = RawReceivePort((dynamic message) {
print('received message $message');
completer.complete(message);
});
await Isolate.spawn(f, [[123], receivePort.sendPort]);
expect(await completer.future, equals('abc'));
receivePort.close();
}, skip: isBrowser);
}
void f(List<dynamic> params) {
final List<int> l = params[0];
final SendPort s = params[1];
print('Received $l');
s.send('abc');
}
@aam
Copy link
Author

aam commented Jun 25, 2019

This test never finishes and prints the following:

Testing started at 07:38 ...
flutter/bin/flutter --no-color test --machine --start-paused test/widgets/isolate_test.dart
Shell: Received [123]
Shell: received message abc

So await at line 15 never seems to get completer completed.

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