Git Product home page Git Product logo

po-simplify's Introduction

PO-simplify介绍

  • PO-simplify项目是对传统的pageObject设计模式进行有大刀阔斧的改革,打破了传统PO设计模式的机械 呆板的设计风

    • 1:优化传统PO设计模式的3层架构 PO-simplify采用传统PO设计模式的设计** 减少Handle(业务层) 将业务层与Buss(操作层)合并,精简Page(页面层)代码,抽取共有方法 在Buss组装逻辑
    • 2:与传统PO设计模式相比PO-simplify直接的业务流程是pagBase->Buss->Case(传统PO模式pageBase->Page->Handle->Buss->Case)
    • 3:综上2点PO-simplify将会大幅度减少代码量,所有数据与业务处理集中在Buss层更加方便做数据驱动、更加方便修改数据来源(例如:Properties文件作为DB修改为MySQL作为数据来源 只用修改Buss层代码即可)
  • 本项目包含了再做自动化测试常用到的一些代码的重构(结合TestNG实现)

    • 1:重写了TestNG的断言方法(Package路径:cn.AnndyTsal.PO.PO_simplify.Assert)
    • 2:实现了TestNG的监听器接口,例如:Assert、Report、Retry、shotScreen等(Package路径:cn.AnndyTsal.PO.PO_simplify.Listener)
  • 请看下列介绍

1:重构断言(Assertion)

  • 本方法包含2部分内容

    • 1:重写Assert方法,Assertion.java(cn.AnndyTsal.PO.PO_simplify.Assert.Assertion)
    • 2:继承TestListenerAdapter类 添加handleAssertion方法
  • 重写断言方法的目的

    • 实现断言失败后其他的Case还会继续执行
  • 参考博客

2:失败截图(shotScreen)

  • 本方法支持注解开启、关闭截图@interface screenshot接口提供了下列3个参数方法:

    • boolean isScreenshot()
    • String name()
    • String file()
  • 参考blog:CSND-失败佛自动截图并保存

3:ExtentX结合ExtendReporter生成报告

  • 注意:本项目有关ExtentX的源码请查考路径:PO_simplify.Listener.Report.ExtentXReport
  • 本项目是一个完整的PageObject设计模式的APP自动化测试基础框架

3.1:ExtentX的简单介绍

  • ExtendReporter只是面向前端的一个静态的HTML页面 每次运行会覆盖前一次的运行结果
  • ExtendReporter结合ExtentX不仅可以提供静态展示的HTML页面还可以在服务端记录每次的运行情况
  • ExtentX的使用需要在服务端安装node.js mongodb forever等

3.2:部署与安装ExtentX

  • 安装部署node.js
  • 下载安装mongodb (不要大于3.6版本)
  • 配置mongodb (这些是基础 baidu就可以了)
  • 该项目根目录下有一个extentx的文件夹 检出项目后 解压,然后进入extentx目录
  • 进入解压目录中,使用命令 npm install, 安装extentx
  • 生产部署 npm install -g forever
  • 进入extentx 目录 forever start -l forever.log -o out.log -e err.log app.js
  • 访问请使用:http://localhost:1337 (这个是localhost的默认配置 其他情况另当别论)

3.3:监听器的使用

testng.xml 中增加listener

<listeners>	
	<listener class-name="cn.AnndyTsal.PO.PO_simplify.Listener.Report.ExtentXReport.ExtentTestNGITestListener"/>
</listeners>

3.4:效果展示

3.4.1:ExtentX服务端的Report截图

ext1 ext2

3.4.2:ExtendReporter静态HTML效果截图

ext3

3.5:温馨提示

  • ExtentX再本项目中是服务于自动化测试的一个Report系统的一部分
  • 请结合全文或者全部源码进行阅读
  • GitHub链接和CSND博客链接如下: PO-simplify CSND-Blog

4:后续项目还会持续更新

po-simplify's People

Contributors

anndytsai avatar

Watchers

 avatar  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.