-
Notifications
You must be signed in to change notification settings - Fork 2
Testing
As a project grows, testing becomes more and more important. In Webelexis, we use the following tools:
- karma as a test runner.
- Mocha as a test framework.
- Chai as assertion library
- Sinon for stubs, mocks and spies
- PhantomJS or Chrome as test environments. PhantomJS is needed for headless development and testing.
Diskussion of these tools would be beyond the scope of this text. Here just a description of the setup:
Most of the tools are listed in the devDependencies
section of package.json
. Therefore all are installed, if you simply type npm install
from the webelexis-base directory. You can make life a bit easier, if you add manually npm install -g karma-cli
(sudo npm install -g kama-cli
on Linuxes).
run the test environment with
karma start karma_cfg.js
and run the test suite with
karma run
(from a different console)
All javascript tests are located in src/test/resources/web
note: tests can only run after npm build-client
since tests work on release files.
- To run Tests within a continuous integration suite, see here as an example for Jenkins (some others are also supported)
- To recompile and test after every file change and save, use
npm run watch
. This watches the source directories and launches processing and testing as needed. - To clean, build and run all client side tests once, use
npm run test-client
Junit4. Tests are located in src/test/<programming language>, e.g. src/test/java or src/test/ruby.
Tests depend on rgwch~vertx-mod-mock~x.y.z
and will run against database mocks.
Download junit-4.x.jar and hamcrest-core-1.x.jar and copy them to a suitable directory. Let $JUNIT_HOME point to that directory. Make sure, $VERTX_HOME is set correctly and that testtools-2.0.3-final.jar
(the vert.x test support) is present in the $VERTX_HOME/lib directory. If everything is okay, you should be able to run the full test suite with npm run test-all
from the webelexis-base directory. The runner will download all dependencies automatically, so first run can take some time.