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 ...
Get Dart: Scalable Application Development 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.