Random posts about coding

Mostly blogging about dart.

Unit Testing With Dart and Cordova on iOS

| Comments

Continuing on from following post, the next step forward for building stuff with Dart and Cordova was to get some unit testing. First class to test is Device. The tests created here are specific to the platform and simulator. Did not add any of the device events for testing until I can find a way to generate them from the simulator.

First step is to add unit testing to the pub spec file.

name:  dartdova
description:  A sample dart cordova integration
dependencies:
  js: any
  unittest: 0.2.9+7

Going with useHtmlEnhancedConfiguration() from unittest/html_enhanced_config.dart did not work. Cordova or iPhone simulator seems to swallow up any exceptions or failures in rending, so resorting to the more stripped down version useHtmlIndividualConfiguration() from package:unittest/html_individual_config.dart.

Using gap as a reference it was easy enough to create a working singleton Device class.

Now building the js code with build.sh and launching iPhone simulator in Xcode.app, the passing unit test should be displayed in the simplified version of the unittest output.

unittest_pass

The code for phonegap_from_scratch can be found on github

Comments