Why can't `#import (" dart: unittest ")` work?

I am writing a dart test code:

#import("dart:unittest");
main() {
  test('this is a test', () {
    int x = 2+3;
    expect(x).equals(5);
  });
}

It does not display any errors in the dart editor, but when I click the start button, it reports:

Do not know how to load 'dart:unittest''file:///home/freewind/dev/dart/editor
/samples/shuzu.org/test/model_test.dart': 
Error: line 1 pos 1: library handler failed
#import("dart:unittest");
^

I see that in my dart-sdk there is a library "dart: unittest". Why can't it be started?

+5
source share
2 answers

Unfortunately, the unittest library is not yet connected to the dart: namespace namespace. Until this happens, if this happens, you will need to use the relative path to access the unittest library.

Sort of:

#import('path-to-dart/lib/unittest/unitest.dart');

Additional examples are given here: http://api.dartlang.org/unittest.html

+7
source

Google dart unittest, . unittest pub, Dart. , , :

Add pub support Dart. ( ) unittest pubspec.yaml. :

name:  range
description:  A sample application

dependencies:
    unittest: { sdk: unittest }

pub install (, Dart, ). , , :

import "package:unittest/unittest.dart";

.

0

All Articles