from pages.add_article_page import ArticleclassifyPage import allure from common.read_yml import readyml ''' allure对用例的等级划分成五个等级 blocker 阻塞缺陷(功能未实现,无法下一步) critical 严重缺陷(功能点缺失) normal 一般缺陷(边界情况,格式错误) minor 次要缺陷(界面错误与ui需求不符) trivial 轻微缺陷(必须项无提示,或者提示不规范) ''' import os curpath = os.path.dirname(os.path.realpath(__file__)) a = readyml(os.path.join(curpath, 'testdata.yml')) # print(a['test_add_param_demo']) testdata = a['test_add_param_demo'] # 测试数据单独拿出来 # testdata = [("测试中文", True), # ("test", True), # ("123456", True), # ] @allure.feature("文章分类") class TestArticleclassify(): @allure.title("编辑文章分类,输入中文,编辑成功") @allure.testcase("http://49.235.92.12:8080/zentao/testcase-view-6-1.html") def test_add_article1(self, login):
url = "http://49.235.92.12:9000/api/v1/userinfo" r = s.get(url) # print(r.text) assert r.json()["msg"] == "sucess!" assert r.json()["code"] == 0 # test_data = [ # ["M", {"message": "update some data!", "code": 0}], # ["F", {"message": "update some data!", "code": 0}], # ["x", {"message": "参数类型错误", "code": 3333}], # ] curpath = os.path.dirname(os.path.realpath(__file__)) yamlpath = os.path.join(curpath, "test_data.yml") test_data = readyml(yamlpath)["updata_info"] @pytest.mark.parametrize("test_input,expect", test_data) def test_updata_info(login_fix, test_input, expect): '''修改个人信息''' s = login_fix url = "http://49.235.92.12:9000/api/v1/userinfo" body = { "name": "test", "sex": test_input, "age": 20, "mail": "*****@*****.**" } r = s.post(url, json=body) print(r.text)
def get_testdata(curPath, testdata): ymlPath = os.path.join(curPath, "test_data.yml") test_data = readyml(ymlPath)[testdata] return test_data
#-*- coding:utf-8 -*- # Author : Cuiwenhao # Time : 2020-03-05 09:13 # Software: PyCharm import os from common.read_yml import readyml # 绝对路径 curPath = os.path.dirname(os.path.realpath(__file__)) print(curPath) yamPath = os.path.join(curPath, "test_data.yml") print(yamPath) test_data = readyml(yamPath)['updata_info'] print(test_data)
# -*- coding:utf-8 -*- # user:wlx import pytest from common.read_yml import readyml import os curpath = os.path.dirname(os.path.dirname(__file__)) a = readyml(os.path.join(curpath, "testdata.yml")) # a = readyml(r'G:\2020\web_pytest_x\case\testdata.yml') testdata = a['test_sum_data'] @pytest.mark.parametrize("test_input, expected", testdata) # @pytest.mark.test1 def test_demo(test_input, expected): a = test_input assert eval(a) == expected @pytest.mark.parametrize("test_input, expected", [["1+2", 3], ["2*3", 6], ["3-7", -4]]) # @pytest.mark.skip(reason="测试跳过") # @pytest.mark.test2 def test_demo2(test_input, expected): a = test_input assert eval(a) == expected
from pages.articleclassify_page import ArticlclassifyPage import pytest from common.read_yml import readyml import os import allure # testdata = [ # ("测试", True), # ("aaaaaaaa", True), # ("11111", True) # ] ymlpath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "articleclassify.yml") print(ymlpath) testdata = readyml(ymlpath).get("article_testdata") print(testdata) @allure.feature("文章分类页面") class TestArticleclassify(): '''文章分类页面''' @allure.story("编辑文章分类,输入中文,编辑成功") @allure.testcase("http://49.235.92.12:8080/zentao/testcase-view-3-1.html") @pytest.mark.parametrize("test_input, expect", testdata) def test_edit_x(self, login, test_input, expect): '''前置条件:1.先登陆 step1: 点文章分类导航标签 step2: 编辑页面输入,分类名称,如:文学 step3: 点保存按钮 ->保存成功 '''
import pytest from pages.add_article_page import ArticleclassifyPage import allure from common.read_yml import readyml ''' allure对用例的等级划分成五个等级 blocker 阻塞缺陷(功能未实现,无法下一步) critical 严重缺陷(功能点缺失) normal 一般缺陷(边界情况,格式错误) minor 次要缺陷(界面错误与ui需求不符) trivial 轻微缺陷(必须项无提示,或者提示不规范) ''' a = readyml(r'D:\soft\code\web_pytest_2020\case\testdata.yml') # print(a['test_add_param_demo']) testdata = a['test_add_param_demo'] # 测试数据单独拿出来 # testdata = [("测试中文", True), # ("test", True), # ("123456", True), # ] @allure.feature("文章分类") class TestArticleclassify(): @allure.title("编辑文章分类,输入中文,编辑成功") @allure.testcase("http://49.235.92.12:8080/zentao/testcase-view-6-1.html") def test_add_article1(self, login): '''用例描述:1.先登陆
from common.read_yml import readyml readyml("case/articleclassify.yml")
# -*- coding:utf-8 -*- # user:wlx import pytest from common.read_yml import readyml a = readyml(r'G:\2020\web_pytest_x\case\testdata.yml') testdata = a['test_sum_data'] @pytest.mark.parametrize("test_input, expected", testdata) @pytest.mark.test1 def test_demo(test_input, expected): a = test_input assert eval(a) == expected @pytest.mark.parametrize("test_input, expected", [["1+2", 3], ["2*3", 6], ["3-7", -4]]) # @pytest.mark.skip(reason="测试跳过") @pytest.mark.test2 def test_demo2(test_input, expected): a = test_input assert eval(a) == expected
import pytest from pages.add_article_page import AddArticlePage from common.read_yml import readyml d = readyml(r'E:\web_pytest_2020\cases\testdata.yml') testdata = d['test_add_param_article'] class Test_add_article(): def test_add_article(self, login): '''测试添加文章分类''' driver = login add_article = AddArticlePage(driver) add_article.click_art_cate() add_article.edit_classify('selenium测试') res = add_article.is_addarticle_success('selenium测试') print('编辑是否成功:%s' % res) assert res @pytest.mark.parametrize('test_input,excepted', testdata) def test_add_param_article(self, login, test_input, excepted): '''用例描述:1,先登录 2,点文章分类导航标签 3,编辑页面输入,分类名称 4,点击保存按钮''' driver = login add_article = AddArticlePage(driver) add_article.click_art_cate() add_article.edit_classify(test_input) res = add_article.is_addarticle_success(test_input) print('实际结果是:%s' % res, '期望结果是:%s' % excepted) assert res == excepted