예제 #1
0
class TestLogin():
    # 在所有测试用例之前创建session,实例化登录接口对象  ->setup_class
    def setup_class(self):
        # 获取session对象
        self.session = requests.session()
        # 实例化登录接口对象
        self.login_object = ApiLogin()

    @allure.feature('登录功能')
    @allure.story('登录的参数:正向和逆向')
    @allure.title('登录的测试用例')
    @allure.severity('critical')
    @pytest.mark.parametrize('accounts, pwd, exp', login_cases, ids=ids)
    def test_login(self, accounts, pwd, exp):
        data = {
            'accounts': accounts,
            'pwd': pwd
        }
        resp = self.login_object.login(self.session, data).json()
        # 做断言 业务层
        assert resp['msg'] == exp
예제 #2
0
class TestLogin:
    # 在所有的测试用例之前做创建session,实例化登录接口对象  ->setup_class
    def setup_class(self):
        # 获取session对象
        self.session = requests.Session()
        # 实例化登录接口对象
        self.login_object = ApiLogin()

    @pytest.mark.parametrize('dic', data_li)
    @allure.title('登录的测试用例')
    @allure.feature('登录功能')
    @allure.story('登录的参数:正向和逆向')
    def test_login(self, dic):
        '''
        data_li是列表套字典的形式用这个测试用例里面的写法
        :param dic:
        :return:
        '''
        # 读取数据,进行构造data,然后发起请求
        data = {'accounts': dic['accounts'], 'pwd': dic['pwd']}
        res = self.login_object.login(self.session, data).json()
        # 做断言
        assert res['msg'] == dic['exp']