Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Overview of Test Framework

Technologies used

  • JUnit 4 (for  for writing tests)
  • Mockito (for  for mocking objects or responses within tests)
  • H2 In-Memory Database (for  for the database backend within test environment)
  • Spring Boot Test (for  for testing the Server Webapp / REST API), which itself uses Hamcrest (matchers), JsonPath (for JSON parsing) and other testing tools.
  • Travis CI - This is our continuous integration system of choice. It automatically runs all code style checks & unit/integration tests for all Pull Requests. Our configuration for Travis CI can be found in our .travis.yml
  • Coveralls - Travis CI runs test code coverage checks which it passes to Coveralls.io for easier display/analysis. If Coveralls finds code coverage has decreased significantly (which means tests were not implemented for new code), it will place a warning on a Pull Request.

...

Overview of Test Framework

...

As the frontend is an Angular.io application (which uses Angular CLI), we follow the best practices for Testing.

Technologies used

  • Jasmine for writing unit/spec tests and Karma for running those tests
  • Protractor for writing integration / end-to-end (e2e) tests
  • Travis CI - This is our continuous integration system of choice. It automatically runs all code style checks & unit/integration tests for all Pull Requests. Our configuration for Travis CI can be found in our .travis.yml
    • Our Travis configuration also starts up a Docker-based REST API backend for running end-to-end (e2e) tests against.
  • Coveralls - Travis CI runs test code coverage checks which it passes to Coveralls.io for easier display/analysis. If Coveralls finds code coverage has decreased significantly (which means tests were not implemented for new code), it will place a warning on a Pull Request.

Test exists in a few key places in the codebase:

  • Unit tests (or specs) can be found throughout the codebase (under /src/app) alongside the code they test. Their filenames always end with ".spec.ts". For example, the login-page.component.ts has a corresponding login-page.component.spec.ts test file.
  • End to End (e2e) tests are all in the /e2e  folder. At this this time we have very few of these.

Checklist for building good tests

...

Writing Unit (spec) Tests

...

A few quick guidelines on writing Unit (or spec) tests using Jasmine:

  • Specs are required for all Angular Components
  • All specs should be placed in the same directory as the Angular Component which they test. The filename should end in ".spec.ts".  For example, the login-page.component.ts has a corresponding login-page.component.spec.ts test file.
  • As much as possible/reasonable, follow the Angular Testing Guide, which provides detailed example tests.  Jasmine also has good documentation/tutorials on learning to write tests.