Thursday, December 13, 2012

Switching to Pub Unittest

‹prev | My Chain | next›

I am in the middle of rewriting the testing chapter in Dart for Hipsters which reminded me that I need update a couple of my packages in the Dart Pub. The unittest library is being moved out of the Dart SDK proper and into a pub-hosted library.

For the dart dirty, this involves changing my only dependency to point to any (e.g. the latest) version of the pub-hosted version of unittest:
name: dirty
version: 0.0.2
description: Dart Dirty is a persistent, server-side HashMap - a dirt simple nosql DB.
author: Chris Strom <>
  unittest: any
After running a pub update, I can again run the test suite and... everything is still passing:
➜  dart-dirty git:(master) ✗ dart test/dirty_test.dart
PASS: new DBs creates a new DB
PASS: writing can write a record to the DB
PASS: reading can read a record from the DB
PASS: reading can read a record from the DB stored on the filesystem
PASS: removing can remove a record from the DB
PASS: removing can remove keys from the DB
PASS: removing can remove a record from the filesystem store
PASS: removing removes from the list of keys in the filesystem store

All 8 tests passed.
Easy enough. I switch my attention instead to Hipster MVC. After updating pubspec.yaml in this project as well, I run the test suite. The test suite is browser-based, and unlike the command-line test suite, this one fails rather spectacularly:

Exception: NoSuchMethodError : method not found: 'set:innerHtml'
Receiver: Instance of 'StyleElement'
That worked just fine before upgrading. I wonder why setting the contents of the style element would not work. Perhaps I just need to try a newer version of Dartium—the test suite itself still passes if I remove the enhanced HTML reporter:
PASS: HipsterCollection has multiple models
PASS: HipsterCollection lookup works by ID
PASS: HipsterCollection lookup is null when it does not hold ID
PASS: HipsterCollection fetch() fails without a url
PASS: HipsterCollection fetch() callback is invoked
PASS: HipsterCollection fetch() callback dispatches a load event
PASS: HipsterCollection add dispatch add event

All 7 tests passed.
And that turns out to be the entirety of the problem. After downloading the latest canary build of Dartium, I reload my test and everything is again working:

With that, I can switch back to rewriting my testing chapter—safe in the knowledge that I can tell readers to use the dart pub version of unittest and have everything work. I was a bit worried for a bit, but it was nothing that a quick update couldn't solve.

Day #598

No comments:

Post a Comment