用pycharm运行pytest

安装pytest

1. 在pycharm中建项目,建文件,文件名字要以test_开头

2.在文件中插入pytest模块

import pytest  #引用pytest模块

3.定义test函数,以及断言

def test_answer():                        #pytest
assert 200 == 200 #断言

def test_answer1(): #pytest
assert 100 == 200 #断言
def test_answer2():                        #pytest
assert [3] == r.json()['ReturnValue'] #断言

4.设置运行函数

run-->edit configuration-->运行文件那一栏填写要运行的文件:test_10strip.test_answer,test_10strip.test_answer1,test_10strip.test_answer2

5.在pycharm选定运行的test函数

6.查看结果

posted @ 2017-10-26 17:28  mghhz816  阅读(942)  评论(1编辑  收藏  举报