我有一个名为Test Case A
的测试用例,我想调试导入的python库中的内部方法调用。我使用PyCharm Run / Debug Configurations窗口设置参数。
/home/zeinab/Workspace/Test/run.py
--testsuite MyDirectory.MyTestSuite --testcases "Test Case A"
/home/zeinab/Workspace/Test
Add content roots to PYTHONPATH
和Add source roots to PYTHONPATH
已经过检查。这是调试器输出:
/usr/bin/python2.7 /home/zeinab/Workspace/lbs-w-report-agent-test/lbs-w/Test/NewTest/run.py --testsuite MyDirectory.MyTestSuite --testcases "Test Case A"
Number of Failed Scenarios: 252
[ ERROR ] Suite 'Scenarios' contains no tests named 'Test Case A' in suite 'MyDirectory.MyTestSuite'.
Try --help for usage information.
Process finished with exit code 1
但是当我复制/粘贴调试器试图执行的行时,检测我的测试用例没有问题。
run.py
包含:
import argparse
if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Robot Test Framework')
parser.add_argument('--file', metavar='f', default="scenarios", help='get path of root scenario')
parser.add_argument('--outputdir', metavar='outputdir', default=DEFAULT_REPORT_DIR, nargs='*', help='get directory for saving output files')
parser.add_argument('--debugfile', metavar='debugfile', default='', nargs='*', help='get file name for saving plain-text log file')
parser.add_argument('--testsuite', metavar='testsuite', default=list(), nargs='*', help='get names of test suits')
parser.add_argument('--tags', metavar='tags', default=list(), nargs='*', help='get name of tags')
parser.add_argument('--critical', metavar='critical', default="", nargs='*', help='get name of tags which should be considered as critical')
parser.add_argument('--testcases', metavar='testcases', default=list(), nargs='*', help='get name of testCases')
parser.add_argument('--skip', metavar='skip', default=list(), nargs='*', help='get name of skip testCases')
parser.add_argument('--loglevel', metavar='loglevel', default="DEBUG", nargs='*', help='get log level')
parser.add_argument('--listener', metavar="listener", default=list(), nargs='*', help='list of listener classes')
arguments = parser.parse_args()
a = run(
arguments.file,
listener=arguments.listener,
outputdir=arguments.outputdir,
debugfile=arguments.outputdir + "/debugfile.log",
report=arguments.outputdir + "/report.html",
log=arguments.outputdir + "/log.html",
output=arguments.outputdir + "/output.xml",
include=arguments.tags,
test=arguments.testcases,
exclude=arguments.skip,
critical=arguments.critical,
suite=arguments.testsuite,
loglevel=':'.join(arguments.loglevel) if type(arguments.loglevel) == list else arguments.loglevel
)
print 'Number of Failed Scenarios:', a
if a != 0:
sys.exit(1)
else:
sys.exit(0)