Compare commits

..

1 Commits
main ... slave1

Author SHA1 Message Date
20220016 01acb3fe31 ADD file via upload
5 months ago

@ -0,0 +1,26 @@
package com.sen.api.functions;
import com.sen.api.utils.RandomUtil;
public class RandomFunction implements Function {
@Override
public String execute(String[] args) {
int len = args.length;
int length = 6;// 默认为6
boolean flag = false;// 默认为false
if (len > 0) {// 第一个参数字符串长度
length = Integer.valueOf(args[0]);
}
if (len > 1) {// 第二个参数是否纯字符串
flag = Boolean.valueOf(args[1]);
}
return RandomUtil.getRandom(length, flag);
}
@Override
public String getReferenceKey() {
return "random";
}
}

@ -1,72 +0,0 @@
import os, shutil
import subprocess, platform
from config.common_path import report_path
import sys, getopt
def clear_reports():
if os.path.exists(report_path):
shutil.rmtree(report_path)
os.mkdir(report_path)
os.mkdir('{}{}picture'.format(report_path, os.path.sep))
def main(argv):
suite_dirs = None
file_names = None
tags = None
environment = None
try:
opts, args = getopt.getopt(argv, "hd:s:t:e:x", ["help", "dir", "suite", "tag", "environment"])
except getopt.GetoptError as e:
print(e)
print('test.py -d <dir> -s <suite> -t <tag> -e <environment>')
sys.exit(2)
for opt, arg in opts:
if opt in ('-h', '--help'):
# print('test.py -d <dir> -s <suite> -t <tag> -e <environment>')
sys.exit()
elif opt in ("-e", "--environment"):
environment = arg
elif opt in ("-d", "--dir"):
suite_dirs = arg
elif opt in ("-s", "--suite"):
file_names = arg.split(';')
elif opt in ("-t", "--tag"):
tags = arg
if not suite_dirs:
suite_dirs = 'smoke_test'
if not file_names:
file_names = ['**.py']
if not tags:
tags = ''
if not environment:
environment = 'test'
return suite_dirs, file_names, tags, environment
if __name__ == '__main__':
clear_reports()
suite_dirs, file_names, tags, environment = main(sys.argv[1:])
# suite_dirs = "smoke_test"
# file_names = ['*09*', '*10*']
# tags = ""
# environment = "test"
print('测试目录:', suite_dirs)
print('测试文件:', file_names)
print('测试标签:', tags)
print('测试环境:', environment)
sub_procs = []
for file_name in file_names:
if platform.system().upper() == 'WINDOWS':
cmd = f'python runner.py -d "{suite_dirs}" -s "{file_name}" -e "{environment}"'
if tags:
cmd += f' -t "{tags}"'
else:
cmd = f'python3 runner.py -d "{suite_dirs}" -s "{file_name}" -e "{environment}"'
if tags:
cmd += f' -t "{tags}"'
print(cmd)
sub_procs.append(subprocess.Popen(cmd, shell=True))
for proc in sub_procs:
proc.wait()
Loading…
Cancel
Save