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 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 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 (here...