Я довольно новичок, чтобы трепетать, поэтому может быть очевидное решение, но я не вижу его.
Всякий раз, когда я запускаю flutter test
внутри своего приложения (или любого другого приложения, см. Ниже), я получаю следующую ошибку:
00:00 +0: loading /Users/johanh/Kod/flutter-projekt/cfmobile/test/widget_test.dart
Compiler message:
file:///var/folders/tr/3tvv8zcd4q302zs0bgbs1h240000gn/T/flutter_test_listener.652XY4/listener.dart:7:8: Error: Error when reading 'file:///Users/johanh/.pub-cache/hosted/pub.dartlang.org/test-1.5.0/lib/src/runner/plugin/remote_platform_helpers.dart': No such file or directory
import 'package:test/src/runner/plugin/remote_platform_helpers.dart';
^
file:///var/folders/tr/3tvv8zcd4q302zs0bgbs1h240000gn/T/flutter_test_listener.652XY4/listener.dart:11:8: Error: Error when reading 'file:///Users/johanh/.pub-cache/hosted/pub.dartlang.org/test-1.5.0/lib/src/runner/vm/catch_isolate_errors.dart': No such file or directory
import 'package:test/src/runner/vm/catch_isolate_errors.dart';
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:14:8: Error: Error when reading 'file:///Users/johanh/.pub-cache/hosted/pub.dartlang.org/test-1.5.0/lib/src/frontend/async_matcher.dart': No such file or directory
import 'package:test/src/frontend/async_matcher.dart'; // ignore: implementation_imports
^
00:02 +0: loading /Users/johanh/Kod/flutter-projekt/cfmobile/test/widget_test.dart file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:283:1: Error: Type 'AsyncMatcher' not found.
AsyncMatcher matchesGoldenFile(dynamic key) {
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:324:1: Error: Type 'AsyncMatcher' not found.
AsyncMatcher matchesReferenceImage(ui.Image image) {
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:530:1: Error: Type 'AsyncMatcher' not found.
AsyncMatcher meetsGuideline(AccessibilityGuideline guideline) {
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:538:1: Error: Type 'AsyncMatcher' not found.
AsyncMatcher doesNotMeetGuideline(AccessibilityGuideline guideline) {
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:1569:38: Error: Type 'AsyncMatcher' not found.
class _MatchesReferenceImage extends AsyncMatcher {
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:1625:34: Error: Type 'AsyncMatcher' not found.
class _MatchesGoldenFile extends AsyncMatcher {
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:1822:46: Error: Type 'AsyncMatcher' not found.
class _MatchesAccessibilityGuideline extends AsyncMatcher {
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:1841:51: Error: Type 'AsyncMatcher' not found.
class _DoesNotMatchAccessibilityGuideline extends AsyncMatcher {
^
00:03 +0: loading /Users/johanh/Kod/flutter-projekt/cfmobile/test/widget_test.dart file:///var/folders/tr/3tvv8zcd4q302zs0bgbs1h240000gn/T/flutter_test_listener.652XY4/listener.dart:20:5: Error: Method not found: 'catchIsolateErrors'.
catchIsolateErrors();
^^^^^^^^^^^^^^^^^^
file:///var/folders/tr/3tvv8zcd4q302zs0bgbs1h240000gn/T/flutter_test_listener.652XY4/listener.dart:19:27: Error: Method not found: 'serializeSuite'.
StreamChannel channel = serializeSuite(() {
^^^^^^^^^^^^^^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:285:12: Error: A value of type '#lib1::_MatchesGoldenFile' can't be assigned to a variable of type 'invalid-type'.
Try changing the type of the left hand side, or casting the right hand side to 'invalid-type'.
return _MatchesGoldenFile(key);
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:287:31: Error: A value of type '#lib1::_MatchesGoldenFile' can't be assigned to a variable of type 'invalid-type'.
Try changing the type of the left hand side, or casting the right hand side to 'invalid-type'.
return _MatchesGoldenFile.forStringPath(key);
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:325:10: Error: A value of type '#lib1::_MatchesReferenceImage' can't be assigned to a variable of type 'invalid-type'.
Try changing the type of the left hand side, or casting the right hand side to 'invalid-type'.
return _MatchesReferenceImage(image);
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:531:10: Error: A value of type '#lib1::_MatchesAccessibilityGuideline' can't be assigned to a variable of type 'invalid-type'.
Try changing the type of the left hand side, or casting the right hand side to 'invalid-type'.
return _MatchesAccessibilityGuideline(guideline);
^
file:///Users/johanh/flutter/packages/flutter_test/lib/src/matchers.dart:539:10: Error: A value of type '#lib1::_DoesNotMatchAccessibilityGuideline' can't be assigned to a variable of type 'invalid-type'.
Try changing the type of the left hand side, or casting the right hand side to 'invalid-type'.
return _DoesNotMatchAccessibilityGuideline(guideline);
^
00:07 +0 -1: loading /Users/johanh/Kod/flutter-projekt/cfmobile/test/widget_test.dart [E]
Failed to load "/Users/johanh/Kod/flutter-projekt/cfmobile/test/widget_test.dart":
Compilation failed
Test: /Users/johanh/Kod/flutter-projekt/cfmobile/test/widget_test.dart
Shell: /Users/johanh/flutter/bin/cache/artifacts/engine/darwin-x64/flutter_tester
00:07 +0 -1: Some tests failed.
Я опустошил widget_test.dart на случай, если с тестом что-то не так:
import 'package:flutter_test/flutter_test.dart';
import 'package:cfmobile/main.dart';
void main() {
testWidgets('Counter increments smoke test', (WidgetTester tester) async {});
}
flutter doctor -v
:
[✓] Flutter (Channel beta, v0.9.4, on Mac OS X 10.13.6 17G65, locale sv-SE)
• Flutter version 0.9.4 at /Users/johanh/flutter
• Framework revision f37c235c32 (6 weeks ago), 2018-09-25 17:45:40 -0400
• Engine revision 74625aed32
• Dart version 2.1.0-dev.5.0.flutter-a2eb050044
[✓] Android toolchain - develop for Android devices (Android SDK 27.0.3)
• Android SDK at /Users/johanh/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-27, build-tools 27.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
• All Android licenses accepted.
[✓] iOS toolchain - develop for iOS devices (Xcode 9.4.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.4.1, Build version 9F2000
• ios-deploy 2.0.0
• CocoaPods version 1.5.2
[✓] Android Studio (version 3.2)
• Android Studio at /Applications/Android Studio.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
[✓] VS Code (version 1.28.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 2.20.0
[✓] Connected devices (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 5.1.1 (API 22) (emulator)
• No issues found!
Что я пробовал:
- Я запустил новое приложение с
flutter create
и, ничего не меняя, запустил тест внутри приложения. Та же ошибка.
- Думая, что мой SDK как-то поврежден, я загрузил его снова.
flutter clean
Обратите внимание, что сами приложения работают просто отлично. Это просто тест, который продолжает сбой.
Может показаться уместным, что я часто получаю это сообщение об ошибке версии при запуске flutter packages get
:
Running "flutter packages get" in cfmobile...
Because every version of flutter_test from sdk depends on http 0.11.3+17 and graphql_flutter 1.0.0-alpha.11 depends on http ^0.12.0, flutter_test from sdk is incompatible with graphql_flutter 1.0.0-alpha.11.
And because no versions of graphql_flutter match >1.0.0-alpha.11 <2.0.0, flutter_test from sdk is incompatible with graphql_flutter ^1.0.0-alpha.11.
So, because cfmobile depends on both graphql_flutter ^1.0.0-alpha.11 and flutter_test any from sdk, version solving failed.
pub get failed (1)
Я решил это, запустив flutter update-packages --force-upgrade
, что помогает с этим, но затем появляется сбой.
Я гуглил это и ничего не нашел. Любая помощь будет принята с благодарностью.