-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Closed
Description
There seems to be a difference between running flutter test and flutter test [path] when it comes to accessing test resources.
Steps to Reproduce
Project structure :
lib/...
test/path_test.dart
test_resources/testfile.txt
testfile.txt just contains an arbitrary string :
This is a test
path_test.dart contains a tests that attempts to load test_resources/testfile.txt :
import 'dart:io';
import 'package:flutter_test/flutter_test.dart';
void main() {
test('Read file test', (){
File f = File("test_resources/testfile.txt");
expect(f.readAsStringSync(),"This is a test");
})
}
Run using path to test file
lutter test test/path_test.dart
00:01 +1: All tests passed!
Run using just flutter test
flutter test
00:01 +0 -1: Read file test [E]
FileSystemException: Cannot open file, path = 'test_resources/testfile.txt' (OS Error: No such file or directory, errno = 2)
dart:io _File.readAsStringSync
path_test.dart 8:16 main.<fn>
00:01 +0 -1: Some tests failed.
Version :
Flutter 1.5.4-hotfix.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 7a4c33425d (3 weeks ago) • 2019-04-29 11:05:24 -0700
Engine • revision 52c7a1e849
Tools • Dart 2.3.0 (build 2.3.0-dev.0.5 a1668566e5)
Running the tests through Android Studio works fine, just the command line command flutter test fails.
Why is there a difference between the commands? Is there a way I can make it work both through my IDE and the flutter test command?
mayurdhurpate and syrokomskyi
Metadata
Metadata
Assignees
Labels
No labels