用于为在线法官创建测试用例的测试用例生成器。

testcase-generator的Python项目详细描述


测试用例生成器

一个测试用例生成器,用于轻松地为在线法官创建测试用例。

安装

$ pip install testcase-generator

或者,克隆这个存储库!

用法

fromtestcase_generatorimportConstraint,Case,Batch,Generator,ConstraintParserdefset_constraints(self):## Write main constraints here ### Sets the constraint of N to be between 1 and 10^3 inclusive.self.N=Constraint(1,10**3)defgenerate_input(self):## Write generator here ### Generates a value for Nyieldself.N.nextCase.SET_CONSTRAINTS=set_constraintsCase.SET_INPUT=generate_input# Using the yaml config to create the batches:config_yaml="""- batch: 1  constraints: {N: 1~10**2}  cases:   - {N: MIN}   - {N: MAX}   - {N: 2~10}   - {N: 10**2-1~}- batch: 2  constraints: {}  cases:   - {}   - {N: ~2}"""p=ConstraintParser(data=config_yaml)p.parse()batches=p.batches# creating the batches manuallybatches=[Batch(num=1,cases=[Case()foriinrange(4)]),Batch(num=2,cases=[Case(N=Constraint(1,10))foriinrange(2)]),]Generator(batches=batches,exe='COMMAND_TO_GENERATE_OUTPUT').start()

生成器具有一个GraphGenerator,它生成多种图形类型:

fromtestcase_generatorimportConstraint,Case,Batch,Generator,ConstraintParser,GraphGenerator""" | initialize(self, N, graph_type, *args, **kwargs) |     N: number of nodes |     graph_type: |              1: normal graph |              2: connected graph |              3: complete graph |              4: circle |              10: line |              11: normal tree |              12: tree, all nodes connected to one node |              13: caterpillar tree |              14: binary tree |     kwargs: |         M: number of edges, leave blank if it is a tree |         duplicates: allow for duplicate edges between nodes |         self_loops: allow for edges between the same node"""defset_constraints(self):## Write main constraints here ### Sets the constraint of N to be between 1 and 10^3 inclusive.# In this case, this is a graph with N nodes.self.N=Constraint(1,10**3)# creates the graph generatorself.ee=GraphGenerator()# Creates the variable that returns the next edge in the graph.# The 1s are filler values.self.E=Constraint(1,1,self.ee.next_edge)# Sets the graph type to be some graph type between 10 and 14.# Please read the initialize method doc for details.# In this case, the graph type is some form of a tree.self.graph_type=Constraint(10,14)defgenerate_input(self):## Write generator here ##n=self.N.nextyieldnself.ee.initialize(n,self.graph_type.next)foriinrange(n-1):yieldself.E.nextCase.SET_CONSTRAINTS=set_constraintsCase.SET_INPUT=generate_input# Using the yaml config to create the batches:config_yaml="""- batch: 1  constraints: {N: 1~10**3-1}  cases:   - {}   - {}   - {}   - {}   - {}   - {}"""p=ConstraintParser(data=config_yaml)p.parse()batches=p.batchesGenerator(batches=batches,exe='COMMAND_TO_GENERATE_OUTPUT').start()

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
Java Double。将长位加倍到C#位转换器。ToDouble   java如何使用正则表达式从固定的Y位数中提取最后的X位数?   java如何显示ChatMessage类列表中的字符串消息属性?   java从JSON或XML提要导入数据,并在Android中创建列表   在整数之间使用按位AND运算符的java好处?   java从Android中的Bean类获取空值?   java会话id对另一台服务器意味着什么?   java未选择案例时开关的工作方式   java组织。openqa。硒。SessionNotCreatedException:无法创建新的远程会话。在emulator中初始化安卓驱动程序时   JavaSWT父和子对话框通信   java请确保java_HOME指向JDK而不是JRE   java用户即使在成功登录后也是匿名的   java控制器单元测试无法自动连接所需的bean   Java小程序类文件