O'Reilly logo

Dart: Scalable Application Development by Ivo Balbaert, Sergey Akopkokhyants, Davy Mitchell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Unit testing

If you are a Test Driven Development advocate you are probably a bit concerned that we have not written any unit tests so far. That is about to change as we introduce the Dart unit test package, which is simply called test (you may see older example code online that uses the older unittest package).

In the sample code for this chapter, there is a sub-folder called Unittest that contains a unit test in bin/main.dart:

library Unittestdemo.test;

import 'package:test/test.dart';

void main() {

  test('HelloWorldTest', () {
    expect(1+1, 2);
  });

}

This defines a new test called HelloWorldTest and the actual test can be carried out by the past in function. The result of the test can be validated using the expect method. The library contains an ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required