Skip to main content

Provide a Framework for Regression Testing

Project description

Regression Framework

This microservice creates a framework for running regression tests

Sample Test Case

The header specifies the runner and the comparator.

The runner is the name of the function that will be used to create the actual results.

The comparator is the name of the function that will be used to compare the actual results to the expected results.

Each test file can contain multiple test cases.

By convention, each test file should correspond to an issue in GitHub.

Each test file should test a single aspect or function of the system, using as many variations in input as are necessary to ensure the design is functional.

engine:
  runner: "mutato"
  comparator: "mutato"
  loglevel: ERROR
  ontologies:
    - unitest

## ---------------------------------------------------------- ##
## Purpose:     Testing Swap for "Doctoral Degree"
## Reference:   https://github.com/craigtrim/owl-parse/issues/6
## ---------------------------------------------------------- ##

cases:
  - id: 06-01
    ## ---------------------------------------------------------- ##
    ##  Purpose:    Span 'doctoral degree'
    ## ---------------------------------------------------------- ##
    input: regression/inputs/tokens-0001.json
    output:
      - normal: "doctoral_degree"

Driver Tutorial

Each project that implements this service will need to create a driver.

The driver is responsible for calling regression-framework\regression_framework\bp\regression_api.py with the correct parameters, as well as implementing the runner(s) and comparator(s).

Driver

A simple but functional driver looks like this:

import os
from typing import Callable
from baseblock import FileIO
from baseblock import BaseObject
from regression_framework.bp import RegressionAPI

class RegressionDriver(BaseObject):

    def __init__(self):
        BaseObject.__init__(self, __name__)

    def find_runner(self,
                    d_test_case: dict) -> Callable:

        runner_name = d_test_case['engine']['runner']

        if runner_name == "mutato":
            return self.runner

        raise NotImplementedError(runner_name)

    def find_comparator(self,
                        d_test_case: dict) -> Callable:

        runner_name = d_test_case['engine']['runner']

        if runner_name == "mutato":
            return self.comparator

        raise NotImplementedError(runner_name)

    def run(self):

        api = RegressionAPI(find_runner=self.find_runner,
                            find_comparator=self.find_comparator)

        api.process(FileIO.join_cwd("regression/cases"))

Note that the driver must implement a finder method for the runner and comparator.

The regression framework supports the notion of multiple runners and multiple comparators and each corresponds to this aspect of the test file:

engine:
  runner: "mutato"
  comparator: "mutato"

Runner

The runner (in this case) looks like this:

def runner(self,
            ontologies: list,
            input_text: str) -> str:

    from owl_parse import owl_parse

    def get_content() -> list:
        if FileIO.exists(input_text):
            return FileIO.read_json(input_text)
        raise NotImplementedError(input_text)

    absolute_path = FileIO.join_cwd('resources/testing')

    return owl_parse(tokens=get_content(),
                        ontology_name=ontologies[0],
                        absolute_path=absolute_path)

It is a simple invocation of a known method, with the correct parameters, and the results are returned.

Comparator

The comparator looks like this:

def comparator(self,
                actual_results: object,
                expected_results: object) -> bool:

    def compare_normal_attribute(expected_value: str) -> bool:
        for actual_result in actual_results:
            if 'normal' in actual_result:
                if actual_result['normal'] == expected_value:
                    return True
        return False

    for expected_result in expected_results:
        if 'normal' in expected_result:
            if not compare_normal_attribute(expected_result['normal']):
                return False

    return True

The actual results are searched and if the expected value(s) are found, the function will return a truth value.

The full implementation is here: https://github.com/craigtrim/regression-framework/issues/2

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

regression-framework-0.1.4.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

regression_framework-0.1.4-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file regression-framework-0.1.4.tar.gz.

File metadata

  • Download URL: regression-framework-0.1.4.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.5 Windows/10

File hashes

Hashes for regression-framework-0.1.4.tar.gz
Algorithm Hash digest
SHA256 68a1195d2989b2e0d954da16a4f7549c510d1afa674e779518290ecef1461458
MD5 ada55d1d30f58b642705b8b9be2541ed
BLAKE2b-256 8e968ef87b41217236ff220adbb4ca3960fd8e8c9c18b447380f29a6d0ebbd8f

See more details on using hashes here.

File details

Details for the file regression_framework-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for regression_framework-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 201c622eecbd7d4d78a76bdc2b90bff678f0e572c7b2ffe6e871ef8d6fac4511
MD5 8d652b21ffe15a59c18fa22d47aeb8a8
BLAKE2b-256 f02e0569033acb53173254221e72d14c1936b56f6147cbc5435f598483b33af5

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page