• run测试用例类的写法.py


    import pytest
    import requests

    #定义预期结果:
    expect = {"title":"V2EX"}

    class TestCase(object):
    def test_case_01(self):
    assert 1

    def test_case_02(self):
    assert {"title":"v2ex"} == {"title":"V2EX"}

    def xxx_case_01(self):
    assert 1

    if __name__ == '__main__':
    #pytest框架自动收集这个脚本里面所有以test开头当成测试用例执行里面的代码
    pytest.main(["-s","run测试用例类的写法.py"]) #高版本以列表写法
    # pytest.main("-s run测试用例类的写法.py") #低版本写法

    """
    结果:
    ============================= test session starts =============================
    platform win32 -- Python 3.6.6, pytest-5.3.2, py-1.8.1, pluggy-0.13.1
    rootdir: D:s27day68
    collected 2 items(收集到两个测试用例)

    run测试用例类的写法.py .(一个成功)F(一个失败)

    ================================== FAILURES(失败信息如下) ===================================
    ____________________________ TestCase.test_case_02 ____________________________

    self = <run测试用例类的写法.TestCase object at 0x0000000003A572B0>

    def test_case_02(self):
    > assert 0
    E assert 0(失败答复)

    run测试用例类的写法.py:14: AssertionError
    ========================= 1 failed, 1 passed in 0.39s =========================

    """
  • 相关阅读:
    ANT安装
    MAVEN配置教程
    闲笔
    js系列
    微信小程序系列_require
    c++复习系列
    codeblocks系列
    mysql系列
    Google Developer Tools
    数学建模算法(三):神经网络
  • 原文地址:https://www.cnblogs.com/zhang-da/p/12217576.html
Copyright © 2020-2023  润新知