【发布时间】:2013-02-20 16:42:04
【问题描述】:
我的单元测试在 Dartium 中没有显示任何内容。它应该显示单元测试结果,但它没有显示任何内容。我的代码如下:
import "package:unittest/unittest.dart";
import "package:unittest/html_config.dart";
import "../../bolsaviaje/web/bolsaviaje.dart" as bolsaviaje;
void main() {
useHtmlConfiguration();
test("PackItem constructor", (){
var item = new bolsaviaje.Cosa("Towel");
expect(item,isNotNull);
});
test("PackItem itemtext propery",(){
var item = new bolsaviaje.Cosa("Towel");
expect(item.nombre,equals("Towel"));
});
}
我的 pubspec.yaml 如下:
name: PackListTest
description: A sample web application
dependencies:
unittest: any
我的 pubspec.lock 如下:
# Generated by pub. See: http://pub.dartlang.org/doc/glossary.html#lockfile
{"packages":{"unittest":{"version":"0.4.1","source":"hosted","description":"unittest"},"meta":{"version":"0.4.1+1","source":"hosted","description":"meta"}}}
我用于单元测试的 HTML 文件的内容如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>PackListTest</title>
<link rel="stylesheet" href="packlisttest.css">
</head>
<body>
<script type="application/dart" src="packlisttest.dart"></script>
</body>
</html>
我使用的 Dart 版本是 Dart M3。
我在两者中都没有获得任何东西:在 Dartium 控制台中什么都没有,在生成的 html 中什么也没有。
不得不说我有两个项目:一个是web应用,另一个是我的单元测试项目。
非常感谢您的帮助。
【问题讨论】:
-
你能把pubspec.yaml、pubspec.lock的内容和你正在使用的SDK或Editor的版本发布出来吗?谢谢!
-
另外,您能否提出您用于驱动测试的 HTML 文件的内容?
-
这里有一堆有效的测试,也许你可以比较一下你在做什么? github.com/sethladd/lawndart/tree/master/test
-
你在 Dartium 控制台和 HTML 中得到了什么?
-
我已经用 Seth Ladd 和 Kai Sellgren 向我询问的信息更新了我的原始帖子。谢谢大家!
标签: unit-testing dart