无法运行单元测试:没有在'Future'类中声明的构造函数'Future.value'

时间:2013-04-18 07:08:20

标签: dart

我有一个新的飞镖项目,但我没有添加单元测试。

但我是DART的新手,所以也许我会受到惩罚,因为所有新手都应该......或者他们应该这样做?

运行单元测试时出错

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 --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插件

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())
  );
}

1 个答案:

答案 0 :(得分:1)

要尝试的几件事情:

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

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