皮瑟斯。关于从pysystest.xml读取数据(+在其上添加新属性)(V0.9.2)

2024-06-28 11:42:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我想读取每个testcase拥有的pysystest.xml文件中的所有数据集。以下是此类文件的示例:

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <pysystest state="runnable" type="auto">
        <description>
            <title>My testcase title</title>
            <purpose><![CDATA[My testcase description is this]]>
            </purpose>
        </description>
        <classification>
            <groups>
                <group>UAT</group>
            </groups>
        </classification>
        <data>
            <class module="run" name="PySysTest"></class>
        </data>
        <traceability>
            <requirements>
                <requirement></requirement>
            </requirements>
        </traceability>
    </pysystest>

框架中是否有API使阅读更容易,或者我必须解析整个XML文件

我还对添加一些自定义属性感兴趣,以便为它们的执行提供一些特定于测试用例的细节。。。框架是否支持此类文件的属性添加功能

提前感谢您的帮助


Tags: 文件datatitlemygroupdescriptionxmltestcase
1条回答
网友
1楼 · 发布于 2024-06-28 11:42:06

pysys.py启动器的打印帮助程序允许您打印详细信息

C:\pysys.py print -h

PySys System Test Framework (version 1.1.0): Console print test helper

Usage: pysys.py print [option]* [tests]*
    where options include;
       -h |  help                 print this message
       -f |  full                 print full information
       -g |  groups               print test groups defined
       -d |  modes                print test modes defined
       -r |  requirements         print test requirements covered
       -m |  mode      STRING     print tests that run in user defined mode
       -a |  type      STRING     print tests of supplied type (auto or manual, default all)
       -t |  trace     STRING     print tests which cover requirement id
       -i |  include   STRING     print tests in included group (can be specified multiple times)
       -e |  exclude   STRING     do not print tests in excluded group (can be specified multiple times)

   and where [tests] describes a set of tests to be printed to the console. Note that multiple test
   sets can be specified, and where none are given all available tests will be run. If an include
   group is given, only tests that belong to that group will be printed. If an exclude group is given,
   tests in the group will not be run. The following syntax is used to select a test set;

       test1    - a single testcase with id test1
       :test2   - upto testcase with id test2
       test1:   - from testcase with id test1 onwards
       id1:id2  - all tests between tests with ids test1 and test2

   e.g.
       pysys.py -i group1 -e group2  full test1:test3

因此,如果您执行pysys.py print-f,您将向stdout输出完整信息。然后,您还可以打印范围内的测试,或在组中定义的测试,或覆盖特定需求的测试等。如果您希望以编程方式解析描述符,可以在pysys.xml包中使用XMLDescriptorParser类。使用文件名创建,然后在该类中有访问器来检索值

相关问题 更多 >