Book Image

Learning Dart, Second Edition - Second Edition

By : Ivo Balbaert
Book Image

Learning Dart, Second Edition - Second Edition

By: Ivo Balbaert

Overview of this book

Table of Contents (18 chapters)
Learning Dart Second Edition
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Testing the Travel Impressions model


After the model is designed, generated, and initialized with some data, the model should be tested to validate it further. In addition, writing tests by applying the techniques we learned in Chapter 3, Structuring Code with Classes and Libraries, is the best way to start learning dartling. Testing is done in the test/travel/impressions/travel_impressions_test.dart file. The main function creates a repository based on the JSON definition of the model and passes it to the testTravelData function:

testTravelData(TravelRepo travelRepo) {
  testTravelImpressions(travelRepo, TravelRepo.travelDomainCode,
      TravelRepo.travelImpressionsModelCode);
}

void main() {
  var travelRepo = new TravelRepo();
  testTravelData(travelRepo);
}

The testTravelImpressions function accepts the repository and the names of the domain and the model. In a group of tests, before each test, a setup is done to first obtain the three variables: models, session, and entries. The models...