maf3-test-runner
v0.1.0
Published
A BDD test runner integrating Karma with MAF3 applications
Downloads
6
Readme
MAF3 Test Runner
Lint and Unit Testing for the MAF 3 framework
Prerequisites
After creating Your application
- To get things started it is simplest to install the
maf3-test-runnerstraight away so that theexamplesdirectory is available immediately undernode_modules/maf3-test-runner
npm install maf3-test-runnerCreate
package.jsonin the root of the project to specify dependencies and test scripts- Copy
examples/package.json - Replace
YOUR_APPLICATION_NAMEin thenamefield
- Copy
Add
node_modulesandreportsto your.gitignorefile
node_modules
reports- Install dependencies
npm installCreate
karma.conf.jsin the root of the project to configure the Karma test runner- Copy
examples/karma.conf.js - Under
preprocessorsset the path to the code to be covered by tests
preprocessors: { '*/.html': [], 'path/to/your/source/code/for/coverage/**/*.js': 'coverage' },- Optionally, change the coverage thresholds ;)
thresholdReporter: { statements: 100, branches: 100, functions: 100, lines: 100 },- Copy
Create
test.htmlin the root of the project to be the bootstrap for the tests- Copy
examples/test.html - Note the name of the application set to autostart, you will create this application later
- Copy
Create
Gruntfile.jsin the root of the project to implement the test scripts- Copy
examples/Gruntfile.js - Replace
YOUR_APPLICATION_NAMEin thefilesarray
- Copy
Create
sonar-project.propertiesin the root of the project to enable sonar analysis- Copy
examples/sonar-project.properties - Replace
YOUR_COMPANY_NAMEwith your comapny name,YOUR_APPLICATION_NAMEandYOUR APPLICATION NAMEwith your application name
- Copy
Create a test application unders
appsto contain the tests,- Copy
examples/apps/com.maf3-test-runner.widget.Testto match the application set to autostart - Add the paths to your source files and tests to the includes in
Contents/Javascript/init.js - Start adding tests!
- Copy
Running tests, etc...
The following scripts will be available using npm
npm testRun the tests once
npm run-script watchWatch the configured files from Gruntfile.js and run tests whenever they change.
npm run-script karmaStart the Karma server and leave it running - useful for debugging as then you can connect any browser to http://localhost:9876 and run the tests or use the debug feature of Karma.
npm run-script karma-runWill start tests in the connected browsers if the Karma server has been started with npm run-script karma
npm startWill start a web server exposing the root of your project at http://localhost:8000. Use this to run your application in a browser.
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using:
$ npm testLicense
Copyright © 2014 Liberty Global
Licensed under the MIT license.

