测试工程师面试问题

1.功能测试、性能测试、自动化测试区别

1.功能测试:
      --又名:黑盒测试
      --依据;需求文档
      --执行:测试用例
      --方法:等价类划分,边界值分析,错误推测,因果图法,判定表驱动分析方法,正交实验设计方法,功能图分析方法
      --错误:功能错误或遗漏,界面错误,数据结构或外部数据库访问错误,性能错误,初始化和终止错误
2.性能测试:
      --包括:负载测试(指标变化),压力测试(性能点),强度测试,容量测试,基准测试,渗入测试,峰谷测试
              应用在客户端性能的测试:负载测试和压力测试
              应用在网络上性能的测试:
              应用在服务器端性能的测试:* Avg Rps: 平均每秒钟响应次数=总请求时间 / 秒数;
                                        * Avg time to last byte per terstion (mstes):平均每秒业务脚本的迭代次数,有人会把这两者混淆;
* Successful Rounds:成功的请求;
* Failed Rounds :失败的请求;
* Successful Hits :成功的点击次数;
* Failed Hits :失败的点击次数;
* Hits Per Second :每秒点击次数;
* Successful Hits Per Second :每秒成功的点击次数;
* Failed Hits Per Second :每秒失败的点击次数;
* Attempted Connections :尝试链接数;
      --具体:通过量、响应时间、CPU负载、内存使用
      --工具:QALoad、LoadRunner、Benchmark Factory、Webstress
      --过程:测试需求与测试内容,测试案例制定,测试环境准备,测试脚本录制、编写与调试,脚本分配、回放配置性能测试图像,性能测试图像与加载策略,测试执行跟踪,结果分析与定位问题所在,测试报告与测试评估。
3.自动化测试:
     --
     --工具:QTP:创建测试、插入检查点、检验数据、增强测试、运行测试、分析结果和维护测试等方面。(回归测试)
             WinRunner:企业级的功能测试工具,用于检测应用程序是否能够达到预期的功能及正常运行。通过自动录制、检测和回放用户的应用操作。
             QA Run:通过鼠标移动、键盘点击操作被测应用,即而得到相应的测试脚本,对该脚本可以进行编辑和调试。
             AutoRunner:功能测试、回归测试
     --前提:需求变动不频繁/项目周期足够长/自动化测试脚本可重复使用
     --过程:自动化测试需求分析,自动化测试框架的搭建(要素:a. 公用的对象。b. 公用的环境。c. 公用的方法。d. 测试数据。)
     --涉及:脚本编写
     --手机自动化测试:Monkey,Monkeyrunner,Appium(常用)
4.其他
     --单元测试框架:java的Junit、testNG,C#的NUnit ,python 的unittest、pytest

2.pytest介绍:

1. 概述

pytest是一个非常成熟的全功能的Python测试框架,主要特点有以下几点:

  • 1、简单灵活,容易上手,文档丰富;
  • 2、支持参数化,可以细粒度地控制要测试的测试用例;
  • 3、能够支持简单的单元测试和复杂的功能测试,还可以用来做selenium/appnium等自动化测试、接口自动化测试(pytest+requests);
  • 4、pytest具有很多第三方插件,并且可以自定义扩展,比较好用的如pytest-selenium(集成selenium)、pytest-html(完美html测试报告生成)、pytest-rerunfailures(失败case重复执行)、pytest-xdist(多CPU分发)等;
  • 5、测试用例的skip和xfail处理;
  • 6、可以很好的和CI工具结合,例如jenkins

2. 使用介绍

2.1. 安装

pip install pytest

2.2. 示例代码

编写规则

编写pytest测试样例非常简单,只需要按照下面的规则:

  • 测试文件以test_开头(以_test结尾也可以)
  • 测试类以Test开头,并且不能带有 init 方法
  • 测试函数以test_开头
  • 断言使用基本的assert即可

pytest1.py

# -*- coding:utf-8 -*-
import pytest

@pytest.fixture(scope='function')
def setup_function(request):
    def teardown_function():
        print("teardown_function called.")
    request.addfinalizer(teardown_function)  # 此内嵌函数做teardown工作
    print('setup_function called.')

@pytest.fixture(scope='module')
def setup_module(request):
    def teardown_module():
        print("teardown_module called.")
    request.addfinalizer(teardown_module)
    print('setup_module called.')

@pytest.mark.website
def test_1(setup_function):
    print('Test_1 called.')

def test_2(setup_module):
    print('Test_2 called.')

def test_3(setup_module):
    print('Test_3 called.')
    assert 2==1+1              # 通过assert断言确认测试结果是否符合预期

fixture的scope参数

scope参数有四种,分别是'function','module','class','session',默认为function。

  • function:每个test都运行,默认是function的scope
  • class:每个class的所有test只运行一次
  • module:每个module的所有test只运行一次
  • session:每个session只运行一次

setup和teardown操作

  • setup,在测试函数或类之前执行,完成准备工作,例如数据库链接、测试数据、打开文件等
  • teardown,在测试函数或类之后执行,完成收尾工作,例如断开数据库链接、回收内存资源等
  • 备注:也可以通过在fixture函数中通过yield实现setup和teardown功能

2.3. 测试结果

如何执行

  • pytest # run all tests below current dir
  • pytest test_mod.py # run tests in module file test_mod.py
  • pytest somepath # run all tests below somepath like ./tests/
  • pytest -k stringexpr # only run tests with names that match the
    # the "string expression", e.g. "MyClass and not method"
    # will select TestMyClass.test_something
    # but not TestMyClass.test_method_simple
  • pytest test_mod.py::test_func # only run tests that match the "node ID",
    # e.g "test_mod.py::test_func" will be selected
    # only run test_func in test_mod.py

通过pytest.mark对test方法分类执行

通过@pytest.mark控制需要执行哪些feature的test,例如在执行test前增加修饰@pytest.mark.website

  • 通过 -m "website" 执行有website标记的test方法
$ pytest  -v -m "website" pytest1.py
============================================================================== test session starts ===============================================================================
platform linux2 -- Python 2.7.14, pytest-3.0.0, py-1.5.2, pluggy-0.3.1 -- /home/kevin/soft/anaconda2/bin/python
cachedir: .cache
Using --randomly-seed=1522925202
rootdir: /home/kevin/learn/python-web/tox/case2, inifile:
plugins: randomly-1.0.0, mock-1.2, cov-2.0.0
collected 3 items

pytest1.py::test_1 PASSED

============================================================================= pytest-warning summary =============================================================================
WC1 None pytest_funcarg__cov: declaring fixtures using "pytest_funcarg__" prefix is deprecated and scheduled to be removed in pytest 4.0.  Please remove the prefix and use the @pytest.fixture decorator instead.
=============================================================================== 2 tests deselected ===============================================================================
=========================================================== 1 passed, 2 deselected, 1 pytest-warnings in 0.00 seconds ============================================================
  • 通过 -m "not website" 执行没有website标记的test方法
$ pytest  -v -m "not website" pytest1.py
============================================================================== test session starts ===============================================================================
platform linux2 -- Python 2.7.14, pytest-3.0.0, py-1.5.2, pluggy-0.3.1 -- /home/kevin/soft/anaconda2/bin/python
cachedir: .cache
Using --randomly-seed=1522925192
rootdir: /home/kevin/learn/python-web/tox/case2, inifile:
plugins: randomly-1.0.0, mock-1.2, cov-2.0.0
collected 3 items

pytest1.py::test_3 PASSED
pytest1.py::test_2 PASSED

============================================================================= pytest-warning summary =============================================================================
WC1 None pytest_funcarg__cov: declaring fixtures using "pytest_funcarg__" prefix is deprecated and scheduled to be removed in pytest 4.0.  Please remove the prefix and use the @pytest.fixture decorator instead.
=============================================================================== 1 tests deselected ===============================================================================
=========================================================== 2 passed, 1 deselected, 1 pytest-warnings in 0.00 seconds ============================================================

Console参数介绍

  • -v 用于显示每个测试函数的执行结果
  • -q 只显示整体测试结果
  • -s 用于显示测试函数中print()函数输出
  • -x, --exitfirst, exit instantly on first error or failed test
  • -h 帮助

Case 1

$ pytest -v pytest1.py
============================================================================== test session starts ===============================================================================
platform linux2 -- Python 2.7.14, pytest-3.0.0, py-1.5.2, pluggy-0.3.1 -- /home/kevin/soft/anaconda2/bin/python
cachedir: .cache
Using --randomly-seed=1522920341
rootdir: /home/kevin/learn/python-web/tox/case2, inifile:
plugins: randomly-1.0.0, mock-1.2, cov-2.0.0
collected 3 items

pytest1.py::test_1 PASSED
pytest1.py::test_3 PASSED
pytest1.py::test_2 PASSED

============================================================================= pytest-warning summary =============================================================================
WC1 None pytest_funcarg__cov: declaring fixtures using "pytest_funcarg__" prefix is deprecated and scheduled to be removed in pytest 4.0.  Please remove the prefix and use the @pytest.fixture decorator instead.
================================================================== 3 passed, 1 pytest-warnings in 0.01 seconds ===================================================================

Case 2

$ pytest -s pytest1.py
============================================================================== test session starts ===============================================================================
platform linux2 -- Python 2.7.14, pytest-3.0.0, py-1.5.2, pluggy-0.3.1
Using --randomly-seed=1522920508
rootdir: /home/kevin/learn/python-web/tox/case2, inifile:
plugins: randomly-1.0.0, mock-1.2, cov-2.0.0
collected 3 items

pytest1.py setup_function called.
Test_1 called.
.teardown_function called.
setup_module called.
Test_2 called.
.Test_3 called.
.teardown_module called.


============================================================================= pytest-warning summary =============================================================================
WC1 None pytest_funcarg__cov: declaring fixtures using "pytest_funcarg__" prefix is deprecated and scheduled to be removed in pytest 4.0.  Please remove the prefix and use the @pytest.fixture decorator instead.
================================================================== 3 passed, 1 pytest-warnings in 0.01 seconds ===================================================================

3. 扩展插件

3.1. 测试报告

安装与样例

pip install pytest-cov # 计算pytest覆盖率,支持输出多种格式的测试报告
pytest --cov-report=html --cov=./ test_code_target_dir

Console参数介绍

  • --cov=[path], measure coverage for filesystem path (multi-allowed), 指定被测试对象,用于计算测试覆盖率
  • --cov-report=type, type of report to generate: term, term-missing, annotate, html, xml (multi-allowed), 测试报告的类型
  • --cov-config=path, config file for coverage, default: .coveragerc, coverage配置文件
  • --no-cov-on-fail, do not report coverage if test run fails, default: False,如果测试失败,不生成测试报告
  • --cov-fail-under=MIN, Fail if the total coverage is less than MIN. 如果测试覆盖率低于MIN,则认为失败

Console Result

---------------------------------------------------------------- coverage: platform linux2, python 2.7.14-final-0 ----------------------------------------------------------------
Name         Stmts   Miss  Cover
--------------------------------
pytest1.py      18      0   100%

Html Result

image.png

3.2. 测试顺序随机

pip install pytest-randomly

3.3. 分布式测试

pip install pytest-xdist

3.4. 出错立即返回

pip install pytest-instafail

3.举例:

(一).我想要回家,让你给我买一张票,然后设计测试用例

答案:

1.确定需求(回家回哪,需要什么票,买什么时候的票)

2.开始测试

2.1功能测试(我去买票(买火车票,飞机票),买到票(什么时候),回来给你)

2.2可靠性测试(我去买票过程中被撞死了,票买不到怎么办,延期了,买那个点的票没了怎么办让我帮他买票的人的身份,比如是否有特殊优待,如军人,1米2以下儿童等,身份证丢了,或者票丢了,责任划分)

2.3可维护性测试(票是否可保存完好)

2.4兼容性(还不同人的去买,我中间招人去买,我坐车走路)

2.5算法测试(我通过不同的渠道买票花费的时间)

2.6竞品测试(别的人怎么买的票)

2.7安全性测试(身份信息保密)

2.8性能测试(一个身份证买多张票,同时多张身份证买多张票)

4.工作测试流程:

(一).功能测试流程

1.需求评审(重点,你发挥的作用是什么,需求可执行性,关联影响的功能模块,异常情况处理)

2.评估测试时间(测试计划)

3.测试用例设计(正交,边界值,等价类。。)

4.用例review(领导,开发,产品)

5.提测(确认开发进行过自测,功能主流程畅通,然后开始介入测试)(产品开发测试一块走流程)

6.codediff(代码改动点,从根源发现开发的问题,代码中明显测试代码(return,写死值),

公共静态变量在发生高并发时容易出问题,所以不能让这个变量的值去内存里面取)

7.执行用例

8.提bug(jira)

9.回归测试

10.确认测试(准生产环境确认)(分情况)

11.发布(线上回归))

12.BUG review(总结问题)

注意点:

发布测试来控制,测试环境部署测试来控制

发布过程中,开发运维做监控。(分批发布)

5.app专项测试:

1.CPU,内存,流量,电量,弱网,兼容性,FPS,中断,安装,稳定性

   怎么自动化实现,写一些自动化框架方法封装起来,重复的使用

2.冷热启动的区别

冷启动:在个人电脑中,冷启动是切断电源后重新启动。App类似,就是完全退出(不在后台运行)后重启启动。

热启动:非冷启动情况都可以称为热启动。热启动比冷启动多了一个触发点,那就是在后台启动App,比如双击苹果的HOME键,进行App的热启动。同时热启动通常会有一个计时器,特别是一些理财和银行的类的App会做此处理,当你间隔一段时间触发了热启动后,会让你再次登录(通过密码/手势/指纹)。也有比如网易新闻客户端这样的,当你间隔一段时间后触发热启动,会弹出广告页。

6.工具使用:

postman:接口,功能测试,可以做参数化

httprequester:接口,功能测试

jemter:接口功能性能工具

lr:接口功能性能

fiddler:抓包,设置代理,设置断点,mock数据

charles:抓包,设置代理,设置断点,mock数据

robot:功能自动化

uft(qtp):功能自动化

docker:容器

monkey:性能稳定性(app)

jenkins:自动持续集成

git,svn:代码管理

xmind/visio:脑图

soapUI:接口功能测试(HTTP,WEBSERVICE协议)

xshell/SecureCRT/putty:

slor:关键字分词

slor:我测试:我   测试分别去数据库搜索结果

nginx(反向代理)

tomcat(动态网页发布)

7.基础概念:

什么是性能测试

HTTP协议(哪些方法,什么区别(GET\POST),怎么组成,状态码)

TCP三次握手四次离手

线程,进程区别联系

内存泄露,内存溢出

死锁

8.自动化测试:

自动化测试脚本的应用场景:

1.重复性较多的,写脚本能省时间,节省效率,

接口重复回归,功能重复回归

2.手动做不了的测试

上万数据的准确性校验,脚本跑,错误数据筛选出来

数据更新机制的调整,全量变成增量更新

自动化框架的搭建:

接口自动化框架

1.结构(1.框架思想(数据,关键字,行为,事件,混合)

2.读取用例的模块(excel,txt,mysql,xml)

3.发请求的模块(requests封装)

4.断言模块(re,遍历断言)

5.日志模块

6.测试报告生成模块

7.发邮件模块

8.配置文件)

2.怎么设计测试用例,注意哪些点()

3.怎么断言

功能自动化框架

1.和接口自动化类似

2.对页面各个控件的api封装(哪些封装,下拉框,选择框,对隐形控件怎么处理)

3.不同环境处理

4.xpath定位方法()

5.js定位方法()

平台工具:

1.接口自动化集成到平台上;

2.平台做测试环境,线上环境的监控

3.做公用统计线上badcase的统计

9.算法:

(会多门语言(前端了解。java熟练,python熟练))

排序算法、冒泡、快排、查找算法、二分查找,

队列,堆,栈实现:

10.linux:

常用命令背下来,熟悉,知道怎么用

ls -alih()

看日志(cat,head,tail,more)

grep|wc -l

11.数据库:

关系型数据库:

mangodb

mysql(sql,慢查询,配置)

oracal

GP数据库

非关系型数据库:

redis

12.服务架构:

服务分布式架构(超融合):概念实现理解

 

13.网络

IP

网关

路由

根据子网掩码算网关

NAT

VPN

交换机配置

14.典型例题

(一).Web页面出现空白页怎么定位问题

1.抓包(抓包)

2.看服务日志

3.看你当前url 用接口实际访问模拟下请求

4.mock数据,给请求,确认是那部分问题

 

(二).Web页面响应过慢怎么定位问题

从一个浏览器输入url到形成页面经历了什么

 

(三).你所测试的系统架构
 

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值