Obtaining the Test Harness

The unittest library is maintained by the core Dart team, but it is not part of the Dart SDK. Instead, it is hosted on the Dart Pub—the package repository for Dart. The easiest way to install this is to create a pubspec.yaml in the application root directory with contents like the following:

testing/pubspec.yaml
 
name: ​Dart Comics
 
dev_dependencies:
 
unittest: ​any

The “any” in there refers to any version of the unittest library, which will default to the most recent version. Since unit testing is not needed for the code to run, it is entered as a dev_dependency instead of a regular dependency.

To install package dependencies, run the pub install command from the command line or from the Tools menu of the Dart Editor. ...

Get Dart 1 for Everyone now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.