Data-Test-Executer Framework speziell zum Test von Datenverarbeitungen mit Datengenerierung, Systemvorbereitungen, Einspielungen, ganzheitlicher diversifizierender Vergleich
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

223 lines
8.9 KiB

#
#
# ----------------------------------------------------------
2 years ago
"""
This program is created for the business-test on the level of unit testing.
On this level there is an intensive test-set up to a carthesian product possible.
The test-specification is written in a yaml-config in the data-directory.
workflow:
1. generate test-cases with all inputs into a csv-file of the spec-yaml
2. run the csv-file and collect all results into a new result-csv-file with all inputs and outputs
3. check the result-csv-file and declare it as a target-results
OR instead 2 and 3 on test-first-strategy:
3. create manually the target-result with your inputs and the target system-outputs
4. run and compare the actual-result with the target-result
5. at the end you get an xls-sheet like your result-csv-file
but additionally with comparsion-result as detailed result and the only counts of passed and failed tests
as minimum-result which can be inserted into management-tools
2 years ago
"""
# Press the green button in the gutter to run the script.
import importlib
import os, glob
import io
import sys
2 years ago
import basic.program
import basic.constants as B
2 years ago
import tools.job_tool as job_tool
import model.catalog
2 years ago
import tools.job_const as J
2 years ago
PROGRAM_NAME = "start_dialog"
2 years ago
verbose = False
def startPyJob(job):
2 years ago
# for debugging write
setattr(job.par, "tool", "job_tool")
# check if an actual job is stored
2 years ago
childArgs = job_tool.read_child_args(job)
if childArgs is None:
childArgs = initDialog(job)
2 years ago
else:
childDialog(job)
pass
2 years ago
def getChoice(job, choiselist, description):
2 years ago
"""
to choise one of the list or exit the program
2 years ago
:param job:
:param choiselist:
:param description:
2 years ago
:return:
"""
2 years ago
index = 0
2 years ago
if isinstance(choiselist, dict):
choiselist = list(choiselist.keys())
if len(choiselist) == 0:
raise Exception("Keine Auswahl zu: "+description)
if len(choiselist) == 1:
return choiselist[0]
2 years ago
print("+------------- "+description+" ----------")
2 years ago
print('| | {:2d} : {:60s}'.format(0, "exit"))
2 years ago
for k in choiselist:
index += 1
2 years ago
print('| | {:2d} : {:60s}'.format(index, k))
2 years ago
print("+-----------------------------------------------")
choice = input("Auswahl 1-" + str(index) + ": ")
2 years ago
if verbose: print("auswahl "+str(choice))
2 years ago
if not choice.isnumeric():
print("FEHLER Fehleingabe "+choice)
getChoice(job, choiselist, description)
elif int(choice) < 1:
job.stopJob(0)
2 years ago
exit(0)
elif int(choice) > index:
print("FEHLER Fehleingabe "+choice)
getChoice(job, choiselist, description)
else:
2 years ago
if verbose: print("treffer "+str(choiselist))
2 years ago
return choiselist[int(choice) - 1]
def initDialog(job, args={}):
"""
dialog to initialize a child-process
:param job:
:return:
"""
# which process
verify = job.getDebugLevel("job_tool")
if "proc" not in args:
2 years ago
args["proc"] = getChoice(job, J.LIST_PROC, "Welchen Prozess starten")
args[J.MODEL_GRAN] = ""
args[B.PAR_USER] = job_tool.getUser()
args[B.PAR_PROJ] = job_tool.getUserProject()
args[B.PAR_STEP] = ""
job.m.logTrace(verify, args["proc"])
# """
if args["proc"] == J.PROC_TP_EXECUTION:
#args[J.MODEL_GRAN] = B.PAR_TESTPLAN
args[B.PAR_STEP] = "1"
2 years ago
args[B.PAR_PROGRAM] = J.PROG_TEST_EXECUTER
elif args["proc"] in [J.PROC_TS_STEPWISE, J.PROC_TS_EXECUTION]:
#args[J.MODEL_GRAN] = B.PAR_TESTSUITE
args[B.PAR_STEP] = "1"
2 years ago
if args["proc"] == J.PROC_TS_EXECUTION:
args[B.PAR_PROGRAM] = J.PROG_TEST_EXECUTER
else:
2 years ago
args[B.PAR_PROGRAM] = J.PROG_TS_INIT
elif args["proc"] in [J.PROC_TC_STEPWISE, J.PROC_TC_EXECUTION]:
#args[J.MODEL_GRAN] = B.PAR_TESTCASE
args[B.PAR_STEP] = "1"
2 years ago
if args["proc"] == J.PROC_TC_EXECUTION:
args[B.PAR_PROGRAM] = J.PROG_TEST_EXECUTER
else:
2 years ago
args[B.PAR_PROGRAM] = J.PROG_TC_INIT
elif args["proc"] == J.PROC_REDO_EXECUTION:
args[B.PAR_PROGRAM] = getChoice(job, J.LIST_TS_PROGS + J.LIST_TC_PROGS,
"Welches Programm starten")
2 years ago
elif args["proc"] == J.PROC_SINGLE_JOB:
args[B.PAR_PROGRAM] = getChoice(job, J.LIST_SERVICE_PROG, "Welches Programm starten")
else:
2 years ago
args[J.MODEL_GRAN] = ""
args[J.MODEL_GRAN] = ""
# """2
catalog = model.catalog.Catalog.getInstance()
programDef = catalog.getValue(job, basic.program.CTLG_NAME, args[B.PAR_PROGRAM], "")
2 years ago
job.m.logTrace(verify, "programdefinition "+str(programDef))
if verbose: print("programdefinition "+args[B.PAR_PROGRAM]+" "+str(programDef))
for p in programDef[basic.program.CTLG_PARDEF]:
2 years ago
job.m.logTrace(verify, "progCtlog "+p+":")
job.m.logTrace(verify, args)
if verbose: print(" "+p+" "+str(args))
if p in args and len(args[p]) > 0:
if verbose: print("arg: " + p+" "+args[p])
job.m.logDebug(verify, "progArg "+p+" ist "+args[p])
elif programDef[basic.program.CTLG_PARDEF][p] == "args":
description = ""
job.m.logDebug(verify, "to select "+p)
if p == B.PAR_GRAN:
description = J.CHOICE_GRAN
choiceList = J.LIST_GRAN
elif p == B.PAR_APP:
description = J.CHOICE_APP
choiceList = job_tool.select_application(job, programDef, args[B.PAR_PROJ])
elif p == J.ARG_TESTELEM:
if verbose: print("testelem "+args[B.PAR_GRAN])
if args[B.PAR_GRAN] in [J.GRAN_TP, B.PAR_TESTPLAN]:
description = J.CHOICE_TP
choiceList = job_tool.select_testplan(job, programDef, args)
p = B.PAR_TESTPLAN
elif args[B.PAR_GRAN] in [J.GRAN_TS, B.PAR_TESTSUITE]:
description = J.CHOICE_TS
choiceList = job_tool.select_testsuite(job, programDef, args)
p = B.PAR_TESTSUITE
elif args[B.PAR_GRAN] in [J.GRAN_TC, B.PAR_TESTCASE]:
description = J.CHOICE_TC
choiceList = job_tool.select_testcase(job, programDef, args)
p = B.PAR_TESTCASE
else:
raise Exception("unknown testgranularity "+args[B.PAR_GRAN])
elif p == B.PAR_COMP:
description = J.CHOICE_ENV
choiceList = job_tool.select_components(job, programDef, args[B.PAR_PROJ], args[B.PAR_APP])
choiceAll = ",".join(choiceList)
choiceList.append(choiceAll)
2 years ago
elif p == B.PAR_ENV:
description = J.CHOICE_ENV
choiceList = job_tool.select_environment(job, programDef, args[B.PAR_PROJ])
elif p in [B.PAR_TESTPLAN, B.PAR_TESTSUITE, B.PAR_TESTCASE]:
if args["proc"] == J.PROC_REDO_EXECUTION:
description = J.CHOICE_ARCHIV
choiceList = job_tool.select_archiv(job, programDef, args[J.MODEL_GRAN], args[B.PAR_APP])
else:
args[B.PAR_STEP] = "1"
description = J.CHOICE_SPEC
choiceList = job_tool.select_spec(job, programDef, args[J.MODEL_GRAN], args)
elif p in [B.PAR_TSTIME, B.PAR_TCTIME] and args["proc"] in [J.PROC_REDO_EXECUTION]:
description = J.CHOICE_TIME
choiceList = job_tool.select_testtime(job, programDef, args[J.MODEL_GRAN], args)
elif p == B.PAR_VAR:
description = J.CHOICE_VARIANT
choiceList = job_tool.select_variant(job, programDef, args[J.MODEL_GRAN], args)
else:
continue
if choiceList is None:
job.m.logError(verify, "choiceList in None "+p)
args[p] = getChoice(job, choiceList, description)
else:
args[p] = programDef[basic.program.CTLG_PARDEF][p]
2 years ago
job.m.logDebug(verify, "p "+p+" jetzt ")
job.m.logDebug(verify, args[p])
job.m.logDebug(verify, args)
job_tool.write_child_args(job, args)
job_tool.start_child_process(job, args)
childDialog(job)
2 years ago
def childDialog(job):
"""
dialog to manage the child-process
:param job:
:return:
"""
2 years ago
args = job_tool.read_child_args(job)
print("+-----------------------------------------------")
for p in args:
if p in ["proc"]:
continue
if len(args[p]) < 1:
continue
print('+ {:12s} : {:60s}'.format(p, args[p]))
print("+-----------------------------------------------")
initDialog(job)
2 years ago
if __name__ == '__main__':
job = basic.program.Job(PROGRAM_NAME)
# TODO to move to job_tool
args = {}
if isinstance(job.programDef[basic.program.CTLG_PARDEF], dict):
for p in job.programDef[basic.program.CTLG_PARDEF]:
args[p] = job.programDef[basic.program.CTLG_PARDEF][p]
job.setParameter(args)
job.startJob()
startPyJob(job)
job.stopJob(0)