Testing Dart projects with latest release and code coverage
Test your package stable and dev
If you’re using Travis CI, it’s as easy as adding a dart: entry to your .travis.yml file. You can specify dev, stable or both to make sure your code works great on current and future build of the Dart SDK.
language: dart
dart:
- dev
- stable See the dartdoc project for an example.
Here’s a build report for dartdoc on Travis CI.
Getting code coverage with coveralls.io
- Setup an account on coveralls.io using your GitHub account.
- Pick the GitHub repo for your project
- Get the Coveralls “repo token” for the project.
- Populate it in Travis CI Settings as
COVERALLS_TOKEN– or whatever you like. - Add Coveralls to your
travis.shscript.
#!/bin/bash
# Fast fail the script on failures.
set -e
# Run the tests.
dart --checked test/test_all.dart
# If the COVERALLS_TOKEN token is set on travis
# Install dart_coveralls
# Rerun tests with coverage and send to coveralls
if [ "$COVERALLS_TOKEN" ]; then
pub global activate dart_coveralls
pub global run dart_coveralls report \
--token $COVERALLS_TOKEN \
--retry 2 \
--exclude-test-files \
test/test_all.dart
fi See the source_gen project for an example.
Here’s the coverage report for source_gen on Coveralls.
Happy hacking!
