Reputation: 324
My unit test doesn't show anything in Dartium. It is supposed to show the unit test result, but it doesn't show anything. My code is the following:
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"));
});
}
My pubspec.yaml is the following:
name: PackListTest
description: A sample web application
dependencies:
unittest: any
My pubspec.lock is the following:
# 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"}}}
The content of my HTML file I'm using for the unit tests is the following:
<!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>
The version of Dart I'm using is Dart M3.
I don't obtain anything in both: nothing in the Dartium Console and nothing in the html generated.
I have to say that I have two projects: one is the web application, and the another is my unit test Project.
Thanks so much for your help.
Upvotes: 0
Views: 526
Reputation: 324
I've resolved my problem. I've taken two actions. The first one was to move my unit test to the same folder my app is. And the second one was to add this line to my .dart app file at the line 1:
library "whatever"
It doesn't matter what the name of the library is, because in my .dart unit test file I wrote:
import "bolsaviaje.dart"
which is the name of my app
I expect this resolution can help you if you have the same problem.
On the other hand, I don't know if there is a constraint related to having the app and the unit test in two different folders.
Upvotes: 0
Reputation: 14388
You will need to add the following to the HTML
<script src="packages/browser/dart.js"></script>
and add the following dependency to pubspec.yaml
dependencies:
browser: any
Dartium now also uses dart.js
to bootstrap the app.
Upvotes: 1