Code Monkey home page Code Monkey logo

cta-brick's Introduction

cta-brick

Build Status Coverage Status codecov

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

General Overview

Overview

This module provides the Brick class to extend. To implement a brick, you need Brick class in cta-brick to 'extends' and implement your own brick, see Usage. In the design, you probably have many bricks to process some works. Those bricks, you design, must 'extends' from Brick class in cta-brick. The Brick provides some useful methods to implement, see Structure.

Guidelines

We aim to give you brief guidelines here.

  1. Brick Class Usage
  2. Brick Class Structure
  3. Brick Class Constructor
  4. Process in Brick

1. Brick Class Usage

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

const Brick = require("cta-brick");

class SampleBrick extends Brick {
  process(context) {
    // process work here
  }
}

module.exports = SampleBrick;

This example shows how to use Brick. We only implement the important method which is process().

back to top

2. Brick Class Structure

Here is a structure of Brick Class.

class Brick {
  constructor(cementHelper, configuration);

  init(): Promise;

  start(): void;

  validate(context): Promise;
  
  process(context): Promise;

  health(data): void;
}

The Brick Class has five methods.

  • init() - to initialize the brick

  • start() - to start the brick

  • validate() - to perform validation

  • process() - to perform process

  • health() - to operate dependencies health check

To learn about Promise, click here.

back to top

3. Brick Class Constructor

In a constructor, the Brick uses dependencies injection to make the dependencies available within Brick. Those dependencies which are cementHelper and configuration are provided by cta-oss framework.

class SampleBrick extends Brick {
  constructor(cementHelper, configuration) {
    super();  // to bind the dependencies
  }
}

module.exports = SampleBrick;

By calling super(), the cementHelper and configuration are bound and available within class context. They can be accesed in any method via this.cementHelper and this.configuration.

back to top

4. Process in Brick

Here we're going to describe process in Brick.

In CTA-OSS, we can informally define two phases for Bricks.

  • In Initial Phase, Brick's init() and start() will be called to initialize, and then to start

  • In Process Phase, after Brick was started, it is ready for process. When there is incoming context, the Brick's validate() and process() will be called to validate, and then to process some works

back to top


To Do

cta-brick's People

Contributors

jongchana-p avatar kiettisak-angkanawin avatar panit-tr avatar pattama avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

pattama

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.