Package: regression-framework
Regression FrameworkThis microservice creates a framework for running regression testsSample Test CaseThe header specifies therunnerand thecomparator.Therunneris the name of the function that will be used to create theactual results.Thecomparatoris the name of the function that will be used to compare theactual resultsto theexpected 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:ERRORontologies:-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.jsonoutput:-normal:"doctoral_degree"Driver TutorialEach project that implements this service will need to create adriver.The driver is responsible for callingregression-framework\regression_framework\bp\regression_api.pywith the correct parameters, as well as implementing the runner(s) and comparator(s).DriverA simple but functional driver looks like this:importosfromtypingimportCallablefrombaseblockimportFileIOfrombaseblockimportBaseObjectfromregression_framework.bpimportRegressionAPIclassRegressionDriver(BaseObject):def__init__(self):BaseObject.__init__(self,__name__)deffind_runner(self,d_test_case:dict)->Callable:runner_name=d_test_case['engine']['runner']ifrunner_name=="mutato":returnself.runnerraiseNotImplementedError(runner_name)deffind_comparator(self,d_test_case:dict)->Callable:runner_name=d_test_case['engine']['runner']ifrunner_name=="mutato":returnself.comparatorraiseNotImplementedError(runner_name)defrun(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"RunnerThe runner (in this case) looks like this:defrunner(self,ontologies:list,input_text:str)->str:fromowl_parseimportowl_parsedefget_content()->list:ifFileIO.exists(input_text):returnFileIO.read_json(input_text)raiseNotImplementedError(input_text)absolute_path=FileIO.join_cwd('resources/testing')returnowl_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.ComparatorThe comparator looks like this:defcomparator(self,actual_results:object,expected_results:object)->bool:defcompare_normal_attribute(expected_value:str)->bool:foractual_resultinactual_results:if'normal'inactual_result:ifactual_result['normal']==expected_value:returnTruereturnFalseforexpected_resultinexpected_results:if'normal'inexpected_result:ifnotcompare_normal_attribute(expected_result['normal']):returnFalsereturnTrueThe 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