Tool Modules for Compass Test Automation, One of Libraries in CTA-OSS Framework
This module provides the Tool class to extend. We provides the Tool as a tool to be implemented any functionality across bricks and framework.
We aim to give you brief guidelines here.
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.
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.
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.
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.
- More Points