[Turn] python automated testing (2) - automation basic technical principles

This article comes from: https: //www.cnblogs.com/beer/p/5011776.html

1 Overview

Mentioned in the previous article inside: the ability to do the most important thing is to be automated  Look beyond  , to the actual implementation of IT work is  to see the data through the interface .

This ability to master the above is not an easy task, you must have a solid theoretical foundation computer to see the deep-seated nature of things.

 

PS:

This article has revenue collection: "Internet-based software development testing of python (test automation) - the whole collection," Welcome to view:

Internet-based software development testing of Python

2 the logical structure of the application

Database application system  is probably the most typical network applications, and on its software architecture is as follows:

Usually logically divided into four layers:

  1. The user interface layer UI

    Provide end users with interactive man-machine interface

  2. Business Logic Layer BLL

    Database object abstracted from spliced ​​into specific business logic objects, and processes for the organization

  3. Data Access Layer DAL

    DB layer to do ORM, so that the upper application in the manner of manipulating database objects

  4. DB Data Persistence

    Data storage, data persistence, different client data sharing

In a conventional  C / S  under the application framework (e.g., the client application under the Windows), usually a central database server (  DB  ), then the client station corresponding to N ( the DAL-the BLL-the UI  ).

For the  primary testers  , it is possible to understand the software can only stay in the  UI  layer, so the test can be done when thing: day after day, year after year, with the mouse  little point a.

3 Internet software architecture

The basic architecture of the front part of the application which he mentions, although in the  "C / S"  era put forward, but the back has been continued to the present. Until today, the most popular  "ABC / S"  mode:

  • App/Server
  • Browser/Server
  • Client/Server

In fact, in essence put this layer on the client UI, the UI on the Server side.

The client under different platforms have different forms, now popular on the formation of so-called  "ABC / S"  architecture model, this is basically the current Internet has become the standard of the product. Specific architecture is as follows:

Employed between the server and client  Http / Https  communication protocol for data exchange format  Xml / Json  format.

After the above model, software testing methodology would have been some changes:

  • With  cost-effective  highest "encoding format based on the communication interface test", belongs to spend 20% to 80% of the work can be solved
  • Interface testing can be automated, but not mandatory, and development projects use the same language, the use of higher efficiency can be unified scripting language
  • Interface  natural demand to have stability, so automation project does not exist fiddle phenomenon
  • Interface between testers become a platform for many  referees
  • 接口规范来自设计文档,可以实行 设计产生测试,测试驱动开发 的规范模式

有了抽象成数据的能力之后,那么很多看到的东西就可以进行合理的等价转换了:

  1. web页面背景的是红色

    等价于:背景元素的background的颜色属性是 #FF0000

  2. 按钮上显示的字为"Submit"

    等价于:按钮元素的value值为 Submit

  3. 用户执行一次充值活动充了20块钱,他的账号上就多了20元

    等价于:以20为参数调用充值接口,再对比前后两次调用账号查询的接口,相差刚好是充值的参数值

在数据层次编程进行比较就变得很容易了,因为这些都是计算机擅长处理的领域了,自动化也很自然地实现了。

4   更底层的原理

前面讲到了对把软件项目从看到的具体的界面往底层一点抽象成数据的方法。其实还有一些更底层,更绝的,对软件的数据还可以更底层一点和物理世界建立关联(这已经不好用“抽象”或者“具象”来描述了)。

本部分的内容,已经和应用软件的测试的话题有点扯远了,纯粹就当科普吧。

从更广泛的角度来看一个计算机系统,它给人的体验上本质上是做了如下的处理:

人的所有的直观体验都是来自于对模拟量(物理量)的体验,人的交互输入也是来自于模拟量的输入。

人敲击键盘向计算机系统输入文字,键盘将不同一键位产生的脉冲电流传入计算机系统,计算机系统通过芯片和驱动,将这些电流信号转化成数字信号,然后交付数字芯片处理。这样人就完成了 信息的输入 。

计算机系统对这些数据进行计算,存储,传输等等,最后在LCD显示器上通过点亮不同位置的点阵,以形成光学的模拟量输出,传送到人的眼睛里面,人就完成了 信息的获取 。

以上的例子可以简化为:力学物理量产生电学物理量进行输入,计算机数字系统处理后,光学物理量进行输出。

对于计算机系统,输入和输出都是多样的:

  • 输入装置

    各种传感器都可以作为输入的主力,比如现在蓬勃发展的智能硬件,以及炒得火热的 物联网

  • 输出装置

    除了光学的LCD显示器,还有声学的扩音器,还有滚动的轮式机械力学,还有人形走路的机械手臂力学设备。

这些东西都已经是现在互联网行业很流行的元素了。

由于电子技术和通讯领域往往检测的都是物理量,肉眼是很难量化的,所以测试门槛会很高,但是各种检测仪器反而发展得相当好,自动化程度相当高。反观IT行业的上层的应用软件层,人却都过多的依赖于人工去操作,肉眼去观察了,反而忽视了自动化,导致测试行业一直人员素质不高,技术实力太弱,这显然是很不可取的,至少是很不符合目前软件工程行业的时代需求的。

5   小结

本文对应用软件进行了逻辑上的分层,来阐述了软件自动化测试和基本原理,在文章的后半部分对目前流行的 智能硬件 所涉及的电子技术的自动化测试也进行了简单的探讨,希望能够给从来 自动化测试的人也有一点启发。

后面的系列文章将从技术层次来落地这些理论。

总结起来,对于想入这行而且想有深入发展的人,有如下几个结论和建议:

  • 软件的本质不是界面而是数据
  • 要了解软件的本质,必须必须要有良好的计算机基础
  • 从事互联网行业的人可以熟悉linux,尽早建立这种 软件即数据 的世界观
  • 接口做自动化测试是最投入回报比最高的(来自Google的工程师的观点)
  • 要想做好自动化测试,必须有软件开发能力和系统的设计能力

写到这里,最后容我 “安利” 一下 Linux ,因为相比 MacOS 和 Windows 系统,Linux 在界面这一块做得不太好,但是却有强大的CLI交互,支持强大的脚本编写,对于实现自动化是很有帮助的。

Guess you like

Origin www.cnblogs.com/ANT-earth-0711/p/11209156.html