I am trying to test async method with compute() function, but when I run test('Compute test') via Android Studio, it doesn't finish and print only 'Start test'.
The test was run using the command:
../bin/flutter --no-color test --machine --start-paused --plain-name "Compute test" test/test_compute.dart
Test class:
import 'package:flutter/foundation.dart';
import 'package:flutter_test/flutter_test.dart';
int testCompute(int value) {
print('Test compute');
return value + 1;
}
void main() {
test('Compute test', () async {
print('Start test');
int result = await compute(testCompute, 0);
print('End test: $result');
});
}
Someone from Google said you need to run your test with
runAsync()
.Source: https://github.com/flutter/flutter/issues/35484#issuecomment-517931625