测试平台之异步任务调度

知识点

基本资源管理

任务调度

https://www.jenkins.io/doc/book/using/remote-access-api/
https://www.jenkins.io/doc/book/managing/cli/
https://github.com/pycontribs/jenkinsapi

测试用例

通常的测试数据传递方法

  • 直接通过jenkins的params传递全部数据比如yaml json
  • 传递套件的标识 比如 sub_directory 分组 正则匹配等xxx/**xxxx 需要提前同步源代码或者压缩包
echo $task
#安装与更新pytest的依赖

#传递过来的只有id与token,jenkins根据id与token通过curl获取所有的测试用例列表

#执行测试用例
pytest --collect-only

#回传结果到测试平台

测试套件

https://docs.pytest.org/en/stable/usage.html

测试结果

<?xml version="1.0" encoding="utf-8"?>
<testsuites>
    <testsuite errors="0" failures="2" hostname="seveniruby" name="pytest" skipped="1" tests="6" time="0.198"
               timestamp="2021-01-23T16:29:16.576447">
        <testcase classname="test_demo" file="test_demo.py" line="3" name="test_demo_1" time="0.001"></testcase>
        <testcase classname="test_demo" file="test_demo.py" line="7" name="test_demo_fail_1" time="0.002">
            <failure message="assert 1 == 2">def test_demo_fail_1():
                &gt; assert 1 == 2
                E assert 1 == 2

                test_demo.py:9: AssertionError
            </failure>
        </testcase>
        <testcase classname="test_demo" file="test_demo.py" line="11" name="test_skip" time="0.006">
            <skipped message="skip" type="pytest.skip">
                /Users/seveniruby/ke/python_15/HogwartsSDET15/backend/demo/test_demo.py:13: skip
            </skipped>
        </testcase>
        <testcase classname="test_demo" file="test_demo.py" line="14" name="test_params[1-2-3]" time="0.003"></testcase>
        <testcase classname="test_demo" file="test_demo.py" line="14" name="test_params[3-4-7]" time="0.002"></testcase>
        <testcase classname="test_demo" file="test_demo.py" line="14" name="test_params[1-3-5]" time="0.001">
            <failure message="assert (1 + 3) == 5">a = 1, b = 3, c = 5

                @pytest.mark.parametrize(&apos;a,b,c&apos;, [
                [1,2,3],
                [3,4,7],
                [1,3,5]
                ])
                def test_params(a,b,c):
                &gt; assert a+b == c
                E assert (1 + 3) == 5

                test_demo.py:21: AssertionError
            </failure>
        </testcase>
    </testsuite>
</testsuites>

https://docs.qameta.io/allure/#_graphs

课后反馈