1. Mike Speriosu
  2. updown


Clone wiki

updown / Testing

This page contains information on running and writing unit tests for updown.

Running Tests

This is about as simple as it gets.

  1. Be sure you have completed Getting Started. In particular, be sure $UPDOWN_DIR is defined correctly.
  2. Execute this command from the updown project directory: $ updown build test

Alternatively, if you're using IDEA with the SBT console installed, you can just type test in the console.

Writing Tests

Try to write tests that exercise as much of the code as possible, but at the same time, try to keep efficiency in mind. We are going to try to keep it feasible to run tests constantly as a sanity check while we are developing. If the tests start to take too long, we won't use them as frequently.

The testing framework we are using is http:www.scalatest.org/. The website has a ton of documentation on writing tests. Each scala class we have should have an analogous ClassNameTest.scala file in $UPDOWN_DIR/src/test/scala/. Copying one of the tests that are already there is probably a good starting point.

Code Coverage

We have included scct ([Scala Code Coverage Tool|http://mtkopone.github.com/scct/]) in the project, so you can see how much code is exercised by your tests. Just make sure $UPDOWN_DIR is defined, and the do:

$ updown scct

This will run the tests and open the report in firefox (Assuming "firefox" is a valid command on your system). According to the scct folks, firefox is really the only browser that works for the report.

If you like doing thins in separate steps, here they are: Generate the report:

$ updown build clean test-coverage

Then you can view the report:

$ firefox $UPDOWN_DIR/target/coverage-report/index.html