Feature Development - AutolabJS/autolabcli GitHub Wiki

This page explains the overall project structure followed in Autolabcli project and provides guidelines to be followed in order to add a new feature to the project.

Project Structure

index.js
lib/
  cli/
    input/
      init.js
    output/
      init.js
  controller/
    validate/
      init.js
    index.js
    init.js
  model/
    init.js
  utils/
    preference-manager.js

Test Structure

test/
  unit/
    index.js
    lib/
      cli/
        input/
          init.js
        output/
          init.js
      controller/
        validate/
          init.js
        index.js
        init.js
      model/
        init.js
  integration/
    init.js
  feature/
    features/
      init.feature
    steps/
      init.js

To add a new feature

In case a new feature eval command needs to be added, follow these steps to do so.

  • Create a controller \lib\controller\eval.js.
  • Create a corresponding input and output files for the command in \lib\cli\input\eval.js and \lib\cli\output\eval.js respectively. These handle the input and output of the command.
  • input\eval.js should export only one function getInput(). This applies to all other input files.
  • output\eval.js should export only one function sendOutput(). This applies to all other output files.
  • The logic part of the command should go into \lib\model\eval.js.
  • All the communication between these modules should take place in the form of events as described in events doc.

To add tests for the new feature.

3 types of tests need to be added for each new feature, namely,

  • Unit tests - Tests each of input, output, controller and model of the feature individually. After adding these tests for the new feature (eval.js), the new structure of tests folder will be as follows -
test/
unit/
  index.js
  lib/
    cli/
      input/
        init.js
        eval.js
      output/
        init.js
        eval.js
    controller/
      validate/
        init.js
        eval.js
      index.js
      init.js
      eval.js
    model/
      init.js
      eval.js
  • Integration tests - These test integration of all the modules and the correct end-to-end flow of the feature. After adding the integration tests for the new feature (eval.js), the new structure of tests folder will be as follows -
test/
  integration/
    init.js
    eval.js
  • Feature tests - These tests describe the functionality of the feature and provide tests for each of these functionality and also take care of testing the deployment. After adding the feature tests for the new feature (eval.js), the new structure of tests folder will be as follows -
test/
  feature/
    features/
      init.feature
      eval.feature
    steps/
      init.js
      eval.js

For more information on each of these tests read Testing in JavaScript document