首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法运行单元测试:没有在“未来”类中声明的构造函数“Future.value”

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

Stack Overflow用户
提问于 2013-04-18 07:08:20
回答 1查看 227关注 0票数 1

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

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

运行单元测试时出现错误

代码语言:javascript
复制
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信息

代码语言:javascript
复制
€ 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插件

代码语言:javascript
复制
Dart Editor for Eclipse 0.4.7.r21548    com.google.dart.eclipse.feature.feature.group   dartlang.org

test_runner.dart

代码语言:javascript
复制
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

代码语言:javascript
复制
library color_test;

import 'package:unittest/unittest.dart';

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

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-04-18 17:03:36

有几件事要尝试:

  • 看看dart-sdk/lib/异步/future.dart。您看到Future.value工厂构造函数了吗?如果没有,那么SDK就不是正确的版本。我将从命令行和编辑器中检查这一点。
  • 如果您确实在SDK中看到它,请尝试退出并重新启动编辑器。我在这里推测,但是当我们在内部看到这一次时,它表现得好像异步库中有一个缓存的副本已经过时了,并且重新启动使问题进展顺利。
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16076596

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档