“颤振测试”崩溃并出现错误:找不到类型“ AsyncMatcher”

时间:2018-11-04 15:24:51

标签: flutter flutter-test

我很扑朔迷离,所以可能有一个明显的解决方案,但我看不到。

每当我在应用程序(或以下任何应用程序,例如以下应用程序)中运行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解决了这个问题,对此有所帮助,但是随后出现崩溃。

我已经在Google上搜索了,却一无所获。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

flutter update-packages供框架的开发人员和贡献者使用。该命令修改了Flutter存储库,在这种情况下,它已处于损坏状态。您必须还原使用git所做的更改,或重新下载SDK