1

I have a new dart project but I fail to add unit tests.

But I am new to DART so perhaps I am punished as all rookies should ... or should they!?

Error when running unit tests

Error: Exception: No constructor 'Future.value' declared in class 'Future'.

NoSuchMethodError : method not found: 'Future.value'
Receiver: Type: class 'Future'
Arguments: []
Stack Trace: #0      _defer (http://127.0.0.1:3030/Users/gunnar/git/chessbuddy/src/main/webapp/dart/chessmodel/test/packages/unittest/unittest.dart:671:20)
#1      _ensureInitialized (http://127.0.0.1:3030/Users/gunnar/git/chessbuddy/src/main/webapp/dart/chessmodel/test/packages/unittest/unittest.dart:830:11)
#2      ensureInitialized (http://127.0.0.1:3030/Users/gunnar/git/chessbuddy/src/main/webapp/dart/chessmodel/test/packages/unittest/unittest.dart:809:21)
#3      group (http://127.0.0.1:3030/Users/gunnar/git/chessbuddy/src/main/webapp/dart/chessmodel/test/packages/unittest/unittest.dart:585:20)
#4      main (http://127.0.0.1:3030/Users/gunnar/git/chessbuddy/src/main/webapp/dart/chessmodel/test/test_runner.dart:9:8)
FAIL

pub info

€ pub --version
Pub 0.4.7+1.r21548
€ pub cache list
{"packages":
    {"browser":{"version":"0.4.7+1","location":"/Users/gunnar/.pub-cache/hosted/pub.dartlang.org/browser-0.4.7+1"},
     "meta":{"version":"0.4.7+1","location":"/Users/gunnar/.pub-cache/hosted/pub.dartlang.org/meta-0.4.7+1"},
     "stagexl":{"version":"0.7.4","location":"/Users/gunnar/.pub-cache/hosted/pub.dartlang.org/stagexl-0.7.4"},
     "unittest":{"version":"0.4.7+1","location":"/Users/gunnar/.pub-cache/hosted/pub.dartlang.org/unittest-0.4.7+1"}}}

Eclipse plugin

Dart Editor for Eclipse 0.4.7.r21548    com.google.dart.eclipse.feature.feature.group   dartlang.org

test_runner.dart

import 'package:unittest/unittest.dart';
import 'package:unittest/html_enhanced_config.dart';

import 'ChessColor_test.dart' as color_test;

void main() {
  useHtmlEnhancedConfiguration();

  group('Enum tests', color_test.main);
}

ChessColor_test.dart

library color_test;

import 'package:unittest/unittest.dart';

void main() {
  test('isWhite', () =>
    expect(true, WHITE.isWhite())
  );
}
4

1 回答 1

1

有几件事可以尝试:

  • 看看 dart-sdk/lib/async/future.dart。你看到 Future.value 工厂构造函数了吗?如果不是,那么您的 SDK 不是正确的版本。我会从命令行和编辑器中检查这一点。

  • 如果您确实在 SDK 中看到它,请尝试退出并重新启动编辑器。我在这里推测,但是当我们在内部看到这个时,它表现得好像有一个过期的异步库的缓存副本,并且重新启动使问题解决了。

于 2013-04-18T17:03:36.003 回答