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
Built Distribution
File details
Details for the file regression-framework-0.1.2.tar.gz
.
File metadata
- Download URL: regression-framework-0.1.2.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 61c453b8ce3b66206fa5fc93990b8c039bee184a66641b3d12de201e0441dc66 |
|
MD5 | 404fc7272faf83e8427c9cfaf5ee791c |
|
BLAKE2b-256 | 984c067bba330254efd42fe164b8fa8f3ca5c8b502eb17833bb68566ad4b84e5 |
File details
Details for the file regression_framework-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: regression_framework-0.1.2-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.8.5 Windows/10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d89c8ca795ad9d892eb654068f56a3db06da68f499a0e0b12de711fedc8b094e |
|
MD5 | c5985bc5b93423ba4092c081bf768581 |
|
BLAKE2b-256 | 26c676d5caf75bc3c59776d8cfd61225bc36ce0c8d4997148703b679787c9067 |