/cta-tool

Primary LanguageJavaScriptOtherNOASSERTION

cta-tool

Build Status Coverage Status codecov

Tool Modules for Compass Test Automation, One of Libraries in CTA-OSS Framework

General Overview

Overview

This module provides the Tool class to extend. We provides the Tool as a tool to be implemented any functionality across bricks and framework.

Guidelines

We aim to give you brief guidelines here.

  1. Tool Class Usage
  2. Tool Class Structure
  3. Tool Class Constructor
  4. Tool Configuration

1. Tool Class Usage

To create a tool for CTA-OSS Framework, we need to extend the class.

const Tool = require("cta-tool");

class SampleTool extends Tool {
  method1() {
    ...
  }

  method2() {
    ...
  }
}

module.exports = SampleTool;

This example shows how to use Tool. We can implement any methods, which in this example are method1() and method2(), that are provided within this tool.

back to top

2. Tool Class Structure

Here is a structure of Tool Class.

class Tool {
  constructor(dependencies, configuration);
}

Presently, Tool class provides a constructor, not other methods because we aim to provide extensibility on tool.

back to top

3. Tool Class Constructor

In a constructor, the Tool uses dependencies injection to make the dependencies and configuration available within Tool.

class SampleTool extends Tool {
  constructor(dependencies, configuration) {
    super(dependencies, configuration);  // to bind the dependencies and configuration
  }
}

module.exports = SampleTool;

By calling super(), the dependencies and configuration are bound and available within class context. They can be accesed in any method via this.dependencies and this.configuration. You can provide the configuration, while the dependencies are provided by cement. The provided configuration will be validated in contructor.

back to top

4. Tool Configuration

const configuration = {
  name: string;
  singleton: boolean;
  properties: any;
};

class SampleTool extends Tool {
  constructor(dependencies, configuration) {
    super(dependencies, configuration);
    ...
  }

  otherMethod() {
    const name = this.name;
    const singleton = this.singleton;
    const properties = this.properties;
    const configuration = this.configuration;
  }
}

The Tool Configuration has three required fields.

  • name - define the tool name
  • singleton - indicate whether the tool is singleton
  • properties - provide properties

These values are avaliable within Tool class.

back to top


To Do

  • More Points