Giter Site home page Giter Site logo

apiautomationtest's Introduction

avatar

一、环境准备

1、安装python依赖模块

  • pip install -r requirements.txt

2、安装allure

3、安装openjdk8

  • sudo add-apt-repository ppa:openjdk-r/ppa
  • sudo apt-get update
  • sudo apt-get install openjdk-8-jdk

二、修改配置

  • vim config/init.ini 配置需要初始化的项目
  • vim config/projectName.ini 配置测试项目的信息

三、运行测试

  • cd APIAutomationTest/
  • python runTest.py --help
  • python runTest.py 运行cases目录所有的用例
  • python runTest.py -k keyword 运行匹配关键字的用例,会匹配文件名、类名、方法名
  • python runTest.py -d dir 运行指定目录的用例,默认运行cases目录

四、生成测试报告

  • cd APIAutomationTest/
  • python generateReport.py -p 9080
  • 访问地址http://ip:9080
  • 在使用Ubuntu进行报告生成时,请勿使用sudo权限,否则无法生成,allure不支持
  • base 基础请求类
  • cases 测试用例目录
  • common 公共模块
  • config 配置文件
  • init 初始化
  • logs 日志目录
  • output 测试结果输出目录
  • pojo 存放自定义类对象
  • test_data 测试所需的测试数据目录
  • runTest.py 测试运行脚本
  • generateReport.py 报告生成脚本
  • 统一使用python 3.6
  • 编码使用-*- coding:utf8 -*-,且不指定解释器
  • 类/方法的注释均写在class/def下一行,并且用三个双引号形式注释
  • 局部代码注释使用#号
  • 所有的测试模块文件都以test_projectName_moduleName.py命名
  • 所有的测试类都以Test开头,类中方法(用例)都以test_开头
  • 每个测试项目都在cases目录里创建一个目录,且目录都包含有api、scenrarios两个目录
  • case对应setup/teardown的fixture统一命名成fixture_[test_case_method_name]
  • @pytest.mark.skip(reason='该功能已废弃')
  • @pytest.mark.parametrize('key1,key2',[(key1_value1,key2_value2),(key1_value2,key2_value2)])
  • @pytest.mark.usefixture('func_name')
  • 运行pytest时指定的目录内应当有conftest.py,方能在其他模块中使用。@allure.step会影响fixture,故在脚本中不使用@allure.step

avatar

apiautomationtest's People

Contributors

yanchunhuo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.